From 7ac014ee7a86099f26ad8d9d94b73aec39e9b6f7 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 23 Feb 2026 10:43:06 +0700 Subject: [PATCH 1/5] remove CONCIERGE_REPORT_ID onyx connect in Report.ts --- package.json | 2 +- src/libs/actions/Report/index.ts | 11 +- src/libs/actions/Task.ts | 7 +- src/pages/ReportDetailsPage.tsx | 3 +- tests/actions/TaskTest.ts | 295 ++++++++++++++++++++++++++++++- 5 files changed, 303 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 73067434d827..db9eb9c9a290 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "test:debug": "TZ=utc NODE_OPTIONS='--inspect-brk --experimental-vm-modules' jest --runInBand", "perf-test": "NODE_OPTIONS=--experimental-vm-modules npx reassure", "typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc", - "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=425 --cache --cache-location=node_modules/.cache/eslint --cache-strategy content --concurrency=auto", + "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=424 --cache --cache-location=node_modules/.cache/eslint --cache-strategy content --concurrency=auto", "lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 ./scripts/lintChanged.sh", "check-lazy-loading": "ts-node scripts/checkLazyLoading.ts", "lint-watch": "npx eslint-watch --watch --changed", diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index d57d5bb49541..bc4c8a2747e2 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -309,7 +309,6 @@ type AddAttachmentWithCommentParams = { }; const addNewMessageWithText = new Set([WRITE_COMMANDS.ADD_COMMENT, WRITE_COMMANDS.ADD_TEXT_AND_ATTACHMENT]); -let conciergeReportIDOnyxConnect: string | undefined; let deprecatedCurrentUserAccountID = -1; /** @deprecated This value is deprecated and will be removed soon after migration. Use the email from useCurrentUserPersonalDetails hook instead. */ let deprecatedCurrentUserLogin: string | undefined; @@ -319,7 +318,6 @@ Onyx.connect({ callback: (value) => { // When signed out, val is undefined if (!value?.accountID) { - conciergeReportIDOnyxConnect = undefined; return; } // eslint-disable-next-line @typescript-eslint/no-deprecated @@ -328,11 +326,6 @@ Onyx.connect({ }, }); -Onyx.connect({ - key: ONYXKEYS.CONCIERGE_REPORT_ID, - callback: (value) => (conciergeReportIDOnyxConnect = value), -}); - // map of reportID to all reportActions for that report const allReportActions: OnyxCollection = {}; @@ -3805,9 +3798,9 @@ function navigateToMostRecentReport(currentReport: OnyxEntry, conciergeR } } -function getMostRecentReportID(currentReport: OnyxEntry) { +function getMostRecentReportID(currentReport: OnyxEntry, conciergeReportID: string | undefined) { const lastAccessedReportID = findLastAccessedReport(false, false, currentReport?.reportID)?.reportID; - return lastAccessedReportID ?? conciergeReportIDOnyxConnect; + return lastAccessedReportID ?? conciergeReportID; } function joinRoom(report: OnyxEntry, currentUserAccountID: number) { diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index e00ba5ea1f24..b037bf8afc02 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1025,7 +1025,7 @@ function getShareDestination( * @param report - The task report being deleted * @returns The URL to navigate to */ -function getNavigationUrlOnTaskDelete(report: OnyxEntry): string | undefined { +function getNavigationUrlOnTaskDelete(report: OnyxEntry, conciergeReportID: string | undefined): string | undefined { if (!report) { return undefined; } @@ -1040,7 +1040,7 @@ function getNavigationUrlOnTaskDelete(report: OnyxEntry): stri } // If no parent report, try to navigate to most recent report - const mostRecentReportID = getMostRecentReportID(report); + const mostRecentReportID = getMostRecentReportID(report, conciergeReportID); if (mostRecentReportID) { return ROUTES.REPORT_WITH_ID.getRoute(mostRecentReportID); } @@ -1059,6 +1059,7 @@ function deleteTask( hasOutstandingChildTask: boolean, parentReportAction: OnyxEntry, ancestors: ReportUtils.Ancestor[] = [], + conciergeReportID: string | undefined, ) { if (!report) { return; @@ -1183,7 +1184,7 @@ function deleteTask( API.write(WRITE_COMMANDS.CANCEL_TASK, parameters, {optimisticData, successData, failureData}); notifyNewAction(report.reportID, undefined, true); - const urlToNavigateBack = getNavigationUrlOnTaskDelete(report); + const urlToNavigateBack = getNavigationUrlOnTaskDelete(report, conciergeReportID); if (urlToNavigateBack) { Navigation.goBack(); return urlToNavigateBack; diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 4a164662a6ea..b199b17da0a4 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -870,7 +870,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail const deleteTransaction = useCallback(() => { if (caseID === CASES.DEFAULT) { - deleteTask(report, parentReport, isReportArchived, currentUserPersonalDetails.accountID, hasOutstandingChildTask, parentReportAction, ancestors); + deleteTask(report, parentReport, isReportArchived, currentUserPersonalDetails.accountID, hasOutstandingChildTask, parentReportAction, ancestors, conciergeReportID); return; } @@ -923,6 +923,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail deleteTransactions, currentSearchHash, removeTransaction, + conciergeReportID, ]); // Where to navigate back to after deleting the transaction and its report. diff --git a/tests/actions/TaskTest.ts b/tests/actions/TaskTest.ts index 333a34327b88..7ef977341993 100644 --- a/tests/actions/TaskTest.ts +++ b/tests/actions/TaskTest.ts @@ -5,13 +5,26 @@ import Onyx from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import useParentReport from '@hooks/useParentReport'; import useReportIsArchived from '@hooks/useReportIsArchived'; -import {canActionTask, canModifyTask, completeTask, completeTestDriveTask, createTaskAndNavigate, getFinishOnboardingTaskOnyxData} from '@libs/actions/Task'; +import { + canActionTask, + canModifyTask, + completeTask, + completeTestDriveTask, + createTaskAndNavigate, + deleteTask, + getFinishOnboardingTaskOnyxData, + getNavigationUrlOnTaskDelete, +} from '@libs/actions/Task'; // eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking import * as API from '@libs/API'; // eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking import DateUtils from '@libs/DateUtils'; import Navigation from '@libs/Navigation/Navigation'; // eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking +import * as ReportActionsUtils from '@libs/ReportActionsUtils'; +// eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking +import * as ReportModule from '@libs/actions/Report'; +// eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking import * as ReportUtils from '@libs/ReportUtils'; import initOnyxDerivedValues from '@userActions/OnyxDerived'; import CONST from '@src/CONST'; @@ -837,4 +850,284 @@ describe('actions/Task', () => { expect(parentReportActionUpdate).toBeUndefined(); }); }); + + describe('getNavigationUrlOnTaskDelete', () => { + let doesReportHaveVisibleActionsSpy: jest.SpyInstance; + let getMostRecentReportIDSpy: jest.SpyInstance; + + beforeEach(() => { + doesReportHaveVisibleActionsSpy = jest.spyOn(ReportActionsUtils, 'doesReportHaveVisibleActions'); + getMostRecentReportIDSpy = jest.spyOn(ReportModule, 'getMostRecentReportID'); + }); + + afterEach(() => { + doesReportHaveVisibleActionsSpy.mockRestore(); + getMostRecentReportIDSpy.mockRestore(); + }); + + it('should return undefined when report is undefined', () => { + expect(getNavigationUrlOnTaskDelete(undefined, 'concierge_123')).toBeUndefined(); + }); + + it('should return undefined when report has visible actions (should not delete)', () => { + const taskReport = getFakeReport(); + doesReportHaveVisibleActionsSpy.mockReturnValue(true); + + expect(getNavigationUrlOnTaskDelete(taskReport, 'concierge_123')).toBeUndefined(); + }); + + it('should return parent report route when report has parentReportID and no visible actions', () => { + const parentReportID = 'parent_123'; + const taskReport = {...getFakeReport(), parentReportID}; + doesReportHaveVisibleActionsSpy.mockReturnValue(false); + + const result = getNavigationUrlOnTaskDelete(taskReport, 'concierge_123'); + expect(result).toBe(`r/${parentReportID}`); + }); + + it('should return most recent report route when no parentReportID and getMostRecentReportID returns a value', () => { + const taskReport = {...getFakeReport(), parentReportID: undefined}; + const mostRecentReportID = 'recent_456'; + doesReportHaveVisibleActionsSpy.mockReturnValue(false); + getMostRecentReportIDSpy.mockReturnValue(mostRecentReportID); + + const result = getNavigationUrlOnTaskDelete(taskReport, 'concierge_123'); + expect(result).toBe(`r/${mostRecentReportID}`); + expect(getMostRecentReportIDSpy).toHaveBeenCalledWith(taskReport, 'concierge_123'); + }); + + it('should pass conciergeReportID to getMostRecentReportID as fallback', () => { + const taskReport = {...getFakeReport(), parentReportID: undefined}; + const conciergeReportID = 'concierge_789'; + doesReportHaveVisibleActionsSpy.mockReturnValue(false); + getMostRecentReportIDSpy.mockReturnValue(conciergeReportID); + + const result = getNavigationUrlOnTaskDelete(taskReport, conciergeReportID); + expect(result).toBe(`r/${conciergeReportID}`); + expect(getMostRecentReportIDSpy).toHaveBeenCalledWith(taskReport, conciergeReportID); + }); + + it('should return undefined when no parentReportID, no most recent report, and conciergeReportID is undefined', () => { + const taskReport = {...getFakeReport(), parentReportID: undefined}; + doesReportHaveVisibleActionsSpy.mockReturnValue(false); + getMostRecentReportIDSpy.mockReturnValue(undefined); + + expect(getNavigationUrlOnTaskDelete(taskReport, undefined)).toBeUndefined(); + }); + }); + + describe('deleteTask', () => { + let doesReportHaveVisibleActionsSpy: jest.SpyInstance; + let getMostRecentReportIDSpy: jest.SpyInstance; + const mockCurrentUserAccountID = 123; + + beforeEach(async () => { + jest.clearAllMocks(); + writeSpy.mockClear(); + + global.fetch = getGlobalFetchMock(); + + doesReportHaveVisibleActionsSpy = jest.spyOn(ReportActionsUtils, 'doesReportHaveVisibleActions'); + getMostRecentReportIDSpy = jest.spyOn(ReportModule, 'getMostRecentReportID'); + + await act(async () => { + await Onyx.clear(); + await Onyx.set(ONYXKEYS.SESSION, { + email: 'user@example.com', + accountID: mockCurrentUserAccountID, + }); + }); + await waitForBatchedUpdatesWithAct(); + }); + + afterEach(() => { + doesReportHaveVisibleActionsSpy.mockRestore(); + getMostRecentReportIDSpy.mockRestore(); + }); + + it('should return early when report is undefined', () => { + deleteTask(undefined, undefined, false, mockCurrentUserAccountID, false, undefined, [], 'concierge_123'); + // eslint-disable-next-line rulesdir/no-multiple-api-calls + expect(API.write).not.toHaveBeenCalled(); + }); + + it('should call API.write with CancelTask and pass conciergeReportID through to navigation', async () => { + const taskReportID = 'task_report_delete_1'; + const parentReportID = 'parent_report_delete_1'; + const parentReportActionID = 'parent_action_delete_1'; + + const taskReport = { + reportID: taskReportID, + type: CONST.REPORT.TYPE.TASK, + reportName: 'Test Task', + parentReportID, + parentReportActionID, + stateNum: CONST.REPORT.STATE_NUM.OPEN, + statusNum: CONST.REPORT.STATUS_NUM.OPEN, + ownerAccountID: mockCurrentUserAccountID, + }; + + const parentReport = { + reportID: parentReportID, + type: CONST.REPORT.TYPE.CHAT, + }; + + const parentReportAction = { + reportActionID: parentReportActionID, + reportID: parentReportID, + childReportID: taskReportID, + } as OnyxEntry; + + await act(async () => { + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, taskReport); + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${parentReportID}`, parentReport); + }); + await waitForBatchedUpdatesWithAct(); + + doesReportHaveVisibleActionsSpy.mockReturnValue(true); + + deleteTask(taskReport, parentReport, false, mockCurrentUserAccountID, false, parentReportAction, [], 'concierge_123'); + + // eslint-disable-next-line rulesdir/no-multiple-api-calls + expect(API.write).toHaveBeenCalledWith( + 'CancelTask', + expect.objectContaining({ + taskReportID, + }), + expect.objectContaining({ + optimisticData: expect.any(Array), + successData: expect.any(Array), + failureData: expect.any(Array), + }), + ); + }); + + it('should return navigation URL when task report has no visible actions and has parentReportID', async () => { + const taskReportID = 'task_report_delete_2'; + const parentReportID = 'parent_report_delete_2'; + + const taskReport = { + reportID: taskReportID, + type: CONST.REPORT.TYPE.TASK, + reportName: 'Test Task To Delete', + parentReportID, + stateNum: CONST.REPORT.STATE_NUM.OPEN, + statusNum: CONST.REPORT.STATUS_NUM.OPEN, + ownerAccountID: mockCurrentUserAccountID, + }; + + const parentReport = { + reportID: parentReportID, + type: CONST.REPORT.TYPE.CHAT, + }; + + await act(async () => { + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, taskReport); + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${parentReportID}`, parentReport); + }); + await waitForBatchedUpdatesWithAct(); + + // No visible actions means the task report should be deleted + doesReportHaveVisibleActionsSpy.mockReturnValue(false); + + const result = deleteTask(taskReport, parentReport, false, mockCurrentUserAccountID, false, undefined, [], 'concierge_123'); + + expect(result).toBe(`r/${parentReportID}`); + expect(Navigation.goBack).toHaveBeenCalled(); + }); + + it('should return conciergeReportID-based URL when no parentReportID and no recent report', async () => { + const taskReportID = 'task_report_delete_3'; + const conciergeReportID = 'concierge_456'; + + const taskReport = { + reportID: taskReportID, + type: CONST.REPORT.TYPE.TASK, + reportName: 'Orphan Task', + parentReportID: undefined, + stateNum: CONST.REPORT.STATE_NUM.OPEN, + statusNum: CONST.REPORT.STATUS_NUM.OPEN, + ownerAccountID: mockCurrentUserAccountID, + }; + + await act(async () => { + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, taskReport); + }); + await waitForBatchedUpdatesWithAct(); + + doesReportHaveVisibleActionsSpy.mockReturnValue(false); + getMostRecentReportIDSpy.mockReturnValue(conciergeReportID); + + const result = deleteTask(taskReport, undefined, false, mockCurrentUserAccountID, false, undefined, [], conciergeReportID); + + expect(result).toBe(`r/${conciergeReportID}`); + expect(getMostRecentReportIDSpy).toHaveBeenCalledWith(taskReport, conciergeReportID); + expect(Navigation.goBack).toHaveBeenCalled(); + }); + + it('should not return navigation URL when task report has visible actions', async () => { + const taskReportID = 'task_report_delete_4'; + const parentReportID = 'parent_report_delete_4'; + + const taskReport = { + reportID: taskReportID, + type: CONST.REPORT.TYPE.TASK, + reportName: 'Task With Visible Actions', + parentReportID, + stateNum: CONST.REPORT.STATE_NUM.OPEN, + statusNum: CONST.REPORT.STATUS_NUM.OPEN, + ownerAccountID: mockCurrentUserAccountID, + }; + + const parentReport = { + reportID: parentReportID, + type: CONST.REPORT.TYPE.CHAT, + }; + + await act(async () => { + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, taskReport); + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${parentReportID}`, parentReport); + }); + await waitForBatchedUpdatesWithAct(); + + // Has visible actions, so should not navigate away + doesReportHaveVisibleActionsSpy.mockReturnValue(true); + + const result = deleteTask(taskReport, parentReport, false, mockCurrentUserAccountID, false, undefined, [], 'concierge_123'); + + expect(result).toBeUndefined(); + expect(Navigation.goBack).not.toHaveBeenCalled(); + }); + + it('should return undefined when no parentReportID, no recent report, and conciergeReportID is undefined', async () => { + const taskReportID = 'task_report_delete_5'; + + const taskReport = { + reportID: taskReportID, + type: CONST.REPORT.TYPE.TASK, + reportName: 'Orphan Task No Fallback', + parentReportID: undefined, + stateNum: CONST.REPORT.STATE_NUM.OPEN, + statusNum: CONST.REPORT.STATUS_NUM.OPEN, + ownerAccountID: mockCurrentUserAccountID, + }; + + await act(async () => { + await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, taskReport); + }); + await waitForBatchedUpdatesWithAct(); + + doesReportHaveVisibleActionsSpy.mockReturnValue(false); + getMostRecentReportIDSpy.mockReturnValue(undefined); + + const result = deleteTask(taskReport, undefined, false, mockCurrentUserAccountID, false, undefined, [], undefined); + + // API.write should still be called + // eslint-disable-next-line rulesdir/no-multiple-api-calls + expect(API.write).toHaveBeenCalledWith('CancelTask', expect.any(Object), expect.any(Object)); + // But no navigation should happen + expect(result).toBeUndefined(); + expect(Navigation.goBack).not.toHaveBeenCalled(); + }); + }); }); From bdb5d1c2ba75442caad89f4568cf00d32626d078 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 23 Feb 2026 10:53:32 +0700 Subject: [PATCH 2/5] lint fix --- src/libs/actions/Task.ts | 2 +- src/pages/ReportDetailsPage.tsx | 2 +- tests/actions/TaskTest.ts | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index b037bf8afc02..d72ad78549b5 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1058,8 +1058,8 @@ function deleteTask( currentUserAccountID: number, hasOutstandingChildTask: boolean, parentReportAction: OnyxEntry, - ancestors: ReportUtils.Ancestor[] = [], conciergeReportID: string | undefined, + ancestors: ReportUtils.Ancestor[] = [], ) { if (!report) { return; diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index b199b17da0a4..37df3d05e766 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -870,7 +870,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail const deleteTransaction = useCallback(() => { if (caseID === CASES.DEFAULT) { - deleteTask(report, parentReport, isReportArchived, currentUserPersonalDetails.accountID, hasOutstandingChildTask, parentReportAction, ancestors, conciergeReportID); + deleteTask(report, parentReport, isReportArchived, currentUserPersonalDetails.accountID, hasOutstandingChildTask, parentReportAction, conciergeReportID, ancestors); return; } diff --git a/tests/actions/TaskTest.ts b/tests/actions/TaskTest.ts index 7ef977341993..44aa225cf930 100644 --- a/tests/actions/TaskTest.ts +++ b/tests/actions/TaskTest.ts @@ -946,7 +946,7 @@ describe('actions/Task', () => { }); it('should return early when report is undefined', () => { - deleteTask(undefined, undefined, false, mockCurrentUserAccountID, false, undefined, [], 'concierge_123'); + deleteTask(undefined, undefined, false, mockCurrentUserAccountID, false, undefined, 'concierge_123'); // eslint-disable-next-line rulesdir/no-multiple-api-calls expect(API.write).not.toHaveBeenCalled(); }); @@ -986,7 +986,7 @@ describe('actions/Task', () => { doesReportHaveVisibleActionsSpy.mockReturnValue(true); - deleteTask(taskReport, parentReport, false, mockCurrentUserAccountID, false, parentReportAction, [], 'concierge_123'); + deleteTask(taskReport, parentReport, false, mockCurrentUserAccountID, false, parentReportAction, 'concierge_123'); // eslint-disable-next-line rulesdir/no-multiple-api-calls expect(API.write).toHaveBeenCalledWith( @@ -1030,7 +1030,7 @@ describe('actions/Task', () => { // No visible actions means the task report should be deleted doesReportHaveVisibleActionsSpy.mockReturnValue(false); - const result = deleteTask(taskReport, parentReport, false, mockCurrentUserAccountID, false, undefined, [], 'concierge_123'); + const result = deleteTask(taskReport, parentReport, false, mockCurrentUserAccountID, false, undefined, 'concierge_123'); expect(result).toBe(`r/${parentReportID}`); expect(Navigation.goBack).toHaveBeenCalled(); @@ -1058,7 +1058,7 @@ describe('actions/Task', () => { doesReportHaveVisibleActionsSpy.mockReturnValue(false); getMostRecentReportIDSpy.mockReturnValue(conciergeReportID); - const result = deleteTask(taskReport, undefined, false, mockCurrentUserAccountID, false, undefined, [], conciergeReportID); + const result = deleteTask(taskReport, undefined, false, mockCurrentUserAccountID, false, undefined, conciergeReportID); expect(result).toBe(`r/${conciergeReportID}`); expect(getMostRecentReportIDSpy).toHaveBeenCalledWith(taskReport, conciergeReportID); @@ -1093,7 +1093,7 @@ describe('actions/Task', () => { // Has visible actions, so should not navigate away doesReportHaveVisibleActionsSpy.mockReturnValue(true); - const result = deleteTask(taskReport, parentReport, false, mockCurrentUserAccountID, false, undefined, [], 'concierge_123'); + const result = deleteTask(taskReport, parentReport, false, mockCurrentUserAccountID, false, undefined, 'concierge_123'); expect(result).toBeUndefined(); expect(Navigation.goBack).not.toHaveBeenCalled(); @@ -1120,7 +1120,7 @@ describe('actions/Task', () => { doesReportHaveVisibleActionsSpy.mockReturnValue(false); getMostRecentReportIDSpy.mockReturnValue(undefined); - const result = deleteTask(taskReport, undefined, false, mockCurrentUserAccountID, false, undefined, [], undefined); + const result = deleteTask(taskReport, undefined, false, mockCurrentUserAccountID, false, undefined, undefined); // API.write should still be called // eslint-disable-next-line rulesdir/no-multiple-api-calls From b036495d3f1f65f31c78d82547b88aa217504bf3 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 24 Feb 2026 21:52:21 +0700 Subject: [PATCH 3/5] lint fix --- tests/actions/TaskTest.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/actions/TaskTest.ts b/tests/actions/TaskTest.ts index 44aa225cf930..2bd3dfb6a3ac 100644 --- a/tests/actions/TaskTest.ts +++ b/tests/actions/TaskTest.ts @@ -5,6 +5,8 @@ import Onyx from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import useParentReport from '@hooks/useParentReport'; import useReportIsArchived from '@hooks/useReportIsArchived'; +// eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking +import * as ReportModule from '@libs/actions/Report'; import { canActionTask, canModifyTask, @@ -23,8 +25,6 @@ import Navigation from '@libs/Navigation/Navigation'; // eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking import * as ReportActionsUtils from '@libs/ReportActionsUtils'; // eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking -import * as ReportModule from '@libs/actions/Report'; -// eslint-disable-next-line no-restricted-syntax -- this is required to allow mocking import * as ReportUtils from '@libs/ReportUtils'; import initOnyxDerivedValues from '@userActions/OnyxDerived'; import CONST from '@src/CONST'; From 49bf565e9028fe85e5263e0a3f3b63144a8815e4 Mon Sep 17 00:00:00 2001 From: dukenv0307 <129500732+dukenv0307@users.noreply.github.com> Date: Thu, 26 Feb 2026 10:34:02 +0700 Subject: [PATCH 4/5] Update tests/actions/TaskTest.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lucien Akchoté --- tests/actions/TaskTest.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/actions/TaskTest.ts b/tests/actions/TaskTest.ts index 2bd3dfb6a3ac..d3d272c7087e 100644 --- a/tests/actions/TaskTest.ts +++ b/tests/actions/TaskTest.ts @@ -1125,6 +1125,7 @@ describe('actions/Task', () => { // API.write should still be called // eslint-disable-next-line rulesdir/no-multiple-api-calls expect(API.write).toHaveBeenCalledWith('CancelTask', expect.any(Object), expect.any(Object)); + // But no navigation should happen expect(result).toBeUndefined(); expect(Navigation.goBack).not.toHaveBeenCalled(); From 1a9a94ab368969533975bf5be9874cb993d85472 Mon Sep 17 00:00:00 2001 From: dukenv0307 <129500732+dukenv0307@users.noreply.github.com> Date: Thu, 26 Feb 2026 10:36:32 +0700 Subject: [PATCH 5/5] Update tests/actions/TaskTest.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lucien Akchoté --- tests/actions/TaskTest.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/actions/TaskTest.ts b/tests/actions/TaskTest.ts index d3d272c7087e..97e69a53ccce 100644 --- a/tests/actions/TaskTest.ts +++ b/tests/actions/TaskTest.ts @@ -947,6 +947,7 @@ describe('actions/Task', () => { it('should return early when report is undefined', () => { deleteTask(undefined, undefined, false, mockCurrentUserAccountID, false, undefined, 'concierge_123'); + // eslint-disable-next-line rulesdir/no-multiple-api-calls expect(API.write).not.toHaveBeenCalled(); });