diff --git a/src/app/features/tasks/util/is-blank-task.spec.ts b/src/app/features/tasks/util/is-blank-task.spec.ts index 07d38425aa..24525a5ef7 100644 --- a/src/app/features/tasks/util/is-blank-task.spec.ts +++ b/src/app/features/tasks/util/is-blank-task.spec.ts @@ -32,6 +32,12 @@ describe('isBlankTask', () => { expect(isBlankTask(createTaskWithSubTasks())).toBe(true); }); + it('should be true (and not throw) when the title is missing entirely', () => { + const t = createTaskWithSubTasks() as any; + delete t.title; + expect(isBlankTask(t)).toBe(true); + }); + it('should be true when the title is only whitespace', () => { expect(isBlankTask(createTaskWithSubTasks({ title: ' ' }))).toBe(true); }); diff --git a/src/app/features/tasks/util/is-blank-task.ts b/src/app/features/tasks/util/is-blank-task.ts index 23377e8fcb..d4e1399db4 100644 --- a/src/app/features/tasks/util/is-blank-task.ts +++ b/src/app/features/tasks/util/is-blank-task.ts @@ -13,7 +13,9 @@ import { Task, TaskWithSubTasks } from '../task.model'; export const isBlankTask = (task: Task | TaskWithSubTasks): boolean => { const subTasks = (task as TaskWithSubTasks).subTasks; return ( - !task.title.trim() && + // Corrupted/legacy tasks can lack a title entirely; treat that as blank + // instead of crashing the callers (e.g. the delete-undo snack effect). + !task.title?.trim() && !task.notes?.trim() && !task.timeSpent && !task.timeEstimate &&