diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index f2809d2997f..0fcd53d993d 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1266,7 +1266,7 @@ function canActionTask(taskReport: OnyxEntry, sessionAccountID } // When there is no parent report, exit early (this can also happen due to onyx key initialization) - if (!parentReport) { + if (!parentReport && !taskReport?.parentReportID) { return false; } diff --git a/tests/actions/TaskTest.ts b/tests/actions/TaskTest.ts index d1cd2c0b64d..8b9127e4b96 100644 --- a/tests/actions/TaskTest.ts +++ b/tests/actions/TaskTest.ts @@ -112,6 +112,15 @@ describe('actions/Task', () => { expect(canActionTask(taskReportCancelled)).toBe(false); }); + it('returns false if parentReport is undefined and taskReport has no parentReportID', () => { + const task = { + ...taskReport, + parentReportID: undefined, + }; + + expect(canActionTask(task, taskAssigneeAccountID, undefined, false)).toBe(false); + }); + it('returns false if the report is a cancelled task report', () => { // The accountID doesn't matter here because the code will do an early return for the cancelled report expect(canActionTask(taskReportCancelled, 0)).toBe(false);