Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ function canActionTask(taskReport: OnyxEntry<OnyxTypes.Report>, 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;
}

Expand Down
9 changes: 9 additions & 0 deletions tests/actions/TaskTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down