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 @@ -45,7 +45,7 @@
let currentUserEmail = '';
let currentUserAccountID = -1;

Onyx.connect({

Check warning on line 48 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserEmail = value?.email ?? '';
Expand All @@ -54,13 +54,13 @@
});

let allPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>;
Onyx.connect({

Check warning on line 57 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => (allPersonalDetails = value),
});

let quickAction: OnyxEntry<OnyxTypes.QuickAction> = {};
Onyx.connect({

Check warning on line 63 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
callback: (value) => {
quickAction = value;
Expand All @@ -68,7 +68,7 @@
});

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 71 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -81,7 +81,7 @@
});

let allReports: OnyxCollection<OnyxTypes.Report>;
Onyx.connect({

Check warning on line 84 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -90,13 +90,13 @@
});

let introSelected: OnyxEntry<OnyxTypes.IntroSelected> = {};
Onyx.connect({

Check warning on line 93 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_INTRO_SELECTED,
callback: (val) => (introSelected = val),
});

let allReportNameValuePair: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({

Check warning on line 99 in src/libs/actions/Task.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -1266,7 +1266,7 @@
}

// 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
Loading