From 212a5fc9ba5a0b9a07b680876d8729bb98535280 Mon Sep 17 00:00:00 2001 From: Linh Date: Fri, 23 Oct 2026 10:36:08 +0700 Subject: [PATCH 1/4] Remove getReportTransactions from prepareToCleanUpMoneyRequest Use the iouReportTransactions callers already pass to decide whether deleting the expense empties its report, and thread them through getNavigationUrlOnMoneyRequestDelete and getNavigationUrlAfterTrackExpenseDelete, which previously fell back to an empty list. --- config/eslint/eslint.seatbelt.tsv | 1 - src/hooks/useExpenseActions.ts | 3 +++ src/libs/actions/IOU/DeleteMoneyRequest.ts | 11 +++++++---- src/libs/actions/IOU/TrackExpense.ts | 3 +++ .../hooks/useReportDetailsDeleteModal.ts | 3 +++ tests/actions/IOUTest/DeleteMoneyRequestTest.ts | 14 ++++++++++---- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/config/eslint/eslint.seatbelt.tsv b/config/eslint/eslint.seatbelt.tsv index 51fb461b9e9b..c61951b0e546 100644 --- a/config/eslint/eslint.seatbelt.tsv +++ b/config/eslint/eslint.seatbelt.tsv @@ -565,7 +565,6 @@ "../../src/libs/actions/InputFocus/index.web.ts" "no-restricted-syntax" 1 "../../src/libs/actions/IOU/BulkEdit.ts" "@typescript-eslint/no-unsafe-type-assertion" 2 "../../src/libs/actions/IOU/BulkEdit.ts" "no-restricted-syntax" 2 -"../../src/libs/actions/IOU/DeleteMoneyRequest.ts" "@typescript-eslint/no-deprecated/getReportTransactions" 1 "../../src/libs/actions/IOU/DeleteMoneyRequest.ts" "@typescript-eslint/no-unsafe-type-assertion" 1 "../../src/libs/actions/IOU/DeleteMoneyRequest.ts" "no-restricted-syntax" 1 "../../src/libs/actions/IOU/Duplicate.ts" "@typescript-eslint/no-unsafe-type-assertion" 7 diff --git a/src/hooks/useExpenseActions.ts b/src/hooks/useExpenseActions.ts index 0fb1ddd2d909..22cbb4accc96 100644 --- a/src/hooks/useExpenseActions.ts +++ b/src/hooks/useExpenseActions.ts @@ -77,6 +77,7 @@ import usePermissions from './usePermissions'; import {useAllPersonalDetails} from './usePersonalDetails'; import usePersonalPolicy from './usePersonalPolicy'; import useReportIsArchived from './useReportIsArchived'; +import useReportTransactions from './useReportTransactions'; import useRestrictedActionPolicyID from './useRestrictedActionPolicyID'; import useSplitEffectivePolicy from './useSplitEffectivePolicy'; import useTheme from './useTheme'; @@ -140,6 +141,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(iouTransactionID)}`); const [originalTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(transaction?.comment?.originalTransactionID)}`); const {iouReport, chatReport: chatIOUReport, isChatIOUReportArchived} = useGetIOUReportFromReportAction(requestParentReportAction); + const iouReportTransactions = useReportTransactions(iouReport?.reportID); // Global collections const [personalDetails] = useAllPersonalDetails(); @@ -580,6 +582,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic requestParentReportAction, transactionThreadReport, iouReport, + iouReportTransactions, chatIOUReport, isChatIOUReportArchived, getCurrencyDecimals, diff --git a/src/libs/actions/IOU/DeleteMoneyRequest.ts b/src/libs/actions/IOU/DeleteMoneyRequest.ts index 4498ccd95491..60e1eff2e603 100644 --- a/src/libs/actions/IOU/DeleteMoneyRequest.ts +++ b/src/libs/actions/IOU/DeleteMoneyRequest.ts @@ -14,7 +14,6 @@ import { getOutstandingChildRequest, getPersonalDetailsForAccountID, getReimbursableTotal, - getReportTransactions, getUnheldReimbursableTotal, hasOutstandingChildRequest, isArchivedReport, @@ -98,7 +97,7 @@ type PrepareToCleanUpMoneyRequestParams = { reportAction: OnyxTypes.ReportAction | undefined; transactionThreadReport: OnyxEntry; iouReport: OnyxEntry; - iouReportTransactions?: OnyxTypes.Transaction[]; + iouReportTransactions: OnyxTypes.Transaction[]; chatReport: OnyxEntry; isChatReportArchived: boolean | undefined; getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals']; @@ -114,7 +113,7 @@ function prepareToCleanUpMoneyRequest({ reportAction, transactionThreadReport, iouReport, - iouReportTransactions = [], + iouReportTransactions, chatReport, isChatReportArchived, getCurrencyDecimals, @@ -173,7 +172,7 @@ function prepareToCleanUpMoneyRequest({ canUserPerformWriteAction = !!canUserPerformWriteActionReportUtils(chatReport, isChatReportArchived); } // If we are deleting the last transaction on a report, then delete the report too - const shouldDeleteIOUReport = getReportTransactions(iouReportID).filter((trans) => !transactionIDsPendingDeletion?.includes(trans.transactionID)).length === 1; + const shouldDeleteIOUReport = iouReportTransactions.filter((trans) => !transactionIDsPendingDeletion?.includes(trans.transactionID)).length === 1; const iouReportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`]; if (shouldDeleteIOUReport) { @@ -352,6 +351,7 @@ function getNavigationUrlOnMoneyRequestDelete( reportAction: OnyxTypes.ReportAction | undefined, transactionThreadReport: OnyxEntry, iouReport: OnyxEntry, + iouReportTransactions: OnyxTypes.Transaction[], chatReport: OnyxEntry, isChatReportArchived: boolean | undefined, getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals'], @@ -365,6 +365,7 @@ function getNavigationUrlOnMoneyRequestDelete( reportAction, transactionThreadReport, iouReport, + iouReportTransactions, chatReport, isChatReportArchived, getCurrencyDecimals, @@ -449,6 +450,7 @@ function cleanUpMoneyRequest({ reportAction, transactionThreadReport, iouReport, + iouReportTransactions, chatReport, isChatIOUReportArchived, getCurrencyDecimals, @@ -869,6 +871,7 @@ function deleteMoneyRequest({ reportAction, transactionThreadReport, iouReport, + iouReportTransactions, chatReport, isChatIOUReportArchived, getCurrencyDecimals, diff --git a/src/libs/actions/IOU/TrackExpense.ts b/src/libs/actions/IOU/TrackExpense.ts index add7d66e2309..b987f84f63b7 100644 --- a/src/libs/actions/IOU/TrackExpense.ts +++ b/src/libs/actions/IOU/TrackExpense.ts @@ -3053,6 +3053,7 @@ function getNavigationUrlAfterTrackExpenseDelete( transactionID: string | undefined, reportAction: OnyxTypes.ReportAction, iouReport: OnyxEntry, + iouReportTransactions: OnyxTypes.Transaction[], chatIOUReport: OnyxEntry, isChatReportArchived: boolean | undefined, getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals'], @@ -3071,6 +3072,7 @@ function getNavigationUrlAfterTrackExpenseDelete( reportAction, transactionThreadReport, iouReport, + iouReportTransactions, chatIOUReport, isChatReportArchived, getCurrencyDecimals, @@ -3118,6 +3120,7 @@ function deleteTrackExpense({ transactionID, reportAction, iouReport, + iouReportTransactions, chatIOUReport, isChatIOUReportArchived, getCurrencyDecimals, diff --git a/src/pages/DynamicReportDetailsPage/hooks/useReportDetailsDeleteModal.ts b/src/pages/DynamicReportDetailsPage/hooks/useReportDetailsDeleteModal.ts index d07aee9cd73b..f66207e4f040 100644 --- a/src/pages/DynamicReportDetailsPage/hooks/useReportDetailsDeleteModal.ts +++ b/src/pages/DynamicReportDetailsPage/hooks/useReportDetailsDeleteModal.ts @@ -47,6 +47,7 @@ function useReportDetailsDeleteModal(reportID: string, caseID: CaseID, parentRep moneyRequestReport, iouTransactionID, iouReport, + iouReportTransactions = [], chatIOUReport, isChatIOUReportArchived, isSingleTransactionView, @@ -90,6 +91,7 @@ function useReportDetailsDeleteModal(reportID: string, caseID: CaseID, parentRep iouTransactionID, requestParentReportAction, iouReport, + iouReportTransactions, chatIOUReport, isChatIOUReportArchived, getCurrencyDecimals, @@ -101,6 +103,7 @@ function useReportDetailsDeleteModal(reportID: string, caseID: CaseID, parentRep requestParentReportAction, requestParentReportActionChildReport, iouReport, + iouReportTransactions, chatIOUReport, isChatIOUReportArchived, getCurrencyDecimals, diff --git a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts index 53b3eba88273..67e014d5f3e0 100644 --- a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts +++ b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts @@ -74,6 +74,12 @@ const RORY_EMAIL = 'rory@expensifail.com'; const RORY_ACCOUNT_ID = 3; const CARLOS_ACCOUNT_ID = 1; +/** Reads every transaction on the report from Onyx, so a test passes deleteMoneyRequest the same list the app would. */ +async function getReportTransactionsFromOnyx(reportID: string | undefined): Promise { + const allTransactions = await getOnyxValue(ONYXKEYS.COLLECTION.TRANSACTION); + return Object.values(allTransactions ?? {}).filter((transaction): transaction is Transaction => !!transaction && transaction.reportID === reportID); +} + OnyxUpdateManager(); describe('actions/IOU/DeleteMoneyRequest', () => { @@ -457,7 +463,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { transactions: {}, violations: {}, iouReport, - iouReportTransactions: transaction ? [transaction] : [], + iouReportTransactions: await getReportTransactionsFromOnyx(iouReport?.reportID), chatReport, transactionThreadReport: thread, allTransactionViolationsParam: {}, @@ -1185,7 +1191,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { transactions: {}, violations: {}, iouReport, - iouReportTransactions: transaction ? [transaction] : [], + iouReportTransactions: await getReportTransactionsFromOnyx(iouReport?.reportID), chatReport, transactionThreadReport: thread, isChatIOUReportArchived: undefined, @@ -1306,7 +1312,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { transactions: {}, violations: {}, iouReport, - iouReportTransactions: transaction ? [transaction] : [], + iouReportTransactions: await getReportTransactionsFromOnyx(iouReport?.reportID), chatReport, transactionThreadReport: thread, isSingleTransactionView: true, @@ -1550,7 +1556,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { transactions: {}, violations: {}, iouReport, - iouReportTransactions: transaction ? [transaction] : [], + iouReportTransactions: await getReportTransactionsFromOnyx(iouReport?.reportID), chatReport, transactionThreadReport: thread, allTransactionViolationsParam: {}, From 0daf1ef9057208c7222d9e9d4c3650f4bebaea0c Mon Sep 17 00:00:00 2001 From: Linh Date: Mon, 16 Nov 2026 10:38:30 +0700 Subject: [PATCH 2/4] fix: Use params objects for the navigation URL helpers and read all report expenses in tests --- src/hooks/useExpenseActions.ts | 18 +++--- src/libs/actions/IOU/DeleteMoneyRequest.ts | 58 ++++++++++------- src/libs/actions/IOU/TrackExpense.ts | 63 ++++++++++++------- .../hooks/useReportDetailsDeleteModal.ts | 30 ++++----- .../actions/IOUTest/DeleteMoneyRequestTest.ts | 15 ++++- 5 files changed, 114 insertions(+), 70 deletions(-) diff --git a/src/hooks/useExpenseActions.ts b/src/hooks/useExpenseActions.ts index 1ec76e848a24..d0a0d51041ef 100644 --- a/src/hooks/useExpenseActions.ts +++ b/src/hooks/useExpenseActions.ts @@ -582,19 +582,19 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic deleteTransactions([transaction.transactionID], duplicateTransactions, duplicateTransactionViolations, currentSearchHash, false); return; } - const goBackRoute = getNavigationUrlOnMoneyRequestDelete( - transaction.transactionID, - requestParentReportAction, + const goBackRoute = getNavigationUrlOnMoneyRequestDelete({ + transactionID: transaction.transactionID, + reportAction: requestParentReportAction, transactionThreadReport, iouReport, iouReportTransactions, - chatIOUReport, - isChatIOUReportArchived, + chatReport: chatIOUReport, + isChatReportArchived: isChatIOUReportArchived, getCurrencyDecimals, - accountID, - false, - chatIOUReportActions, - ); + currentUserAccountID: accountID, + isSingleTransactionView: false, + chatReportActions: chatIOUReportActions, + }); const deleteNavigateBackUrl = goBackRoute ?? backTo ?? Navigation.getActiveRoute(); setDeleteTransactionNavigateBackUrl(deleteNavigateBackUrl); // The wide RHP close animation was changed, and because of that the expense was deleted right after diff --git a/src/libs/actions/IOU/DeleteMoneyRequest.ts b/src/libs/actions/IOU/DeleteMoneyRequest.ts index c5bcecd066a0..ca3564288b14 100644 --- a/src/libs/actions/IOU/DeleteMoneyRequest.ts +++ b/src/libs/actions/IOU/DeleteMoneyRequest.ts @@ -345,26 +345,42 @@ function prepareToCleanUpMoneyRequest({ }; } +type GetNavigationUrlOnMoneyRequestDeleteParams = { + /** The ID of the money request being deleted */ + transactionID: string | undefined; + + /** The report action associated with the money request */ + reportAction: OnyxTypes.ReportAction | undefined; + transactionThreadReport: OnyxEntry; + iouReport: OnyxEntry; + iouReportTransactions: OnyxTypes.Transaction[]; + chatReport: OnyxEntry; + isChatReportArchived: boolean | undefined; + getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals']; + currentUserAccountID: number; + + /** Whether we are in the transaction thread report */ + isSingleTransactionView?: boolean; + chatReportActions?: OnyxEntry; +}; + /** * Calculate the URL to navigate to after a money request deletion - * @param transactionID - The ID of the money request being deleted - * @param reportAction - The report action associated with the money request - * @param isSingleTransactionView - whether we are in the transaction thread report * @returns The URL to navigate to */ -function getNavigationUrlOnMoneyRequestDelete( - transactionID: string | undefined, - reportAction: OnyxTypes.ReportAction | undefined, - transactionThreadReport: OnyxEntry, - iouReport: OnyxEntry, - iouReportTransactions: OnyxTypes.Transaction[], - chatReport: OnyxEntry, - isChatReportArchived: boolean | undefined, - getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals'], - currentUserAccountID: number, +function getNavigationUrlOnMoneyRequestDelete({ + transactionID, + reportAction, + transactionThreadReport, + iouReport, + iouReportTransactions, + chatReport, + isChatReportArchived, + getCurrencyDecimals, + currentUserAccountID, isSingleTransactionView = false, - chatReportActions?: OnyxEntry, -): Route | undefined { + chatReportActions, +}: GetNavigationUrlOnMoneyRequestDeleteParams): Route | undefined { if (!transactionID) { return undefined; } @@ -461,19 +477,19 @@ function cleanUpMoneyRequest({ chatReportActions, }); - const urlToNavigateBack = getNavigationUrlOnMoneyRequestDelete( + const urlToNavigateBack = getNavigationUrlOnMoneyRequestDelete({ transactionID, reportAction, transactionThreadReport, iouReport, iouReportTransactions, chatReport, - isChatIOUReportArchived, + isChatReportArchived: isChatIOUReportArchived, getCurrencyDecimals, currentUserAccountID, isSingleTransactionView, chatReportActions, - ); + }); // build Onyx data // Onyx operations to delete the transaction, update the IOU report action and chat report action @@ -887,19 +903,19 @@ function deleteMoneyRequest({ chatReportActions, }); - const urlToNavigateBack = getNavigationUrlOnMoneyRequestDelete( + const urlToNavigateBack = getNavigationUrlOnMoneyRequestDelete({ transactionID, reportAction, transactionThreadReport, iouReport, iouReportTransactions, chatReport, - isChatIOUReportArchived, + isChatReportArchived: isChatIOUReportArchived, getCurrencyDecimals, currentUserAccountID, isSingleTransactionView, chatReportActions, - ); + }); // STEP 2: Build Onyx data // The logic mostly resembles the cleanUpMoneyRequest function diff --git a/src/libs/actions/IOU/TrackExpense.ts b/src/libs/actions/IOU/TrackExpense.ts index 72cc6a2c16a7..989a62b4d9b6 100644 --- a/src/libs/actions/IOU/TrackExpense.ts +++ b/src/libs/actions/IOU/TrackExpense.ts @@ -3058,27 +3058,44 @@ function trackExpense(params: CreateTrackExpenseParams) { return {iouReport, transactionID: transaction?.transactionID}; } +type GetNavigationUrlAfterTrackExpenseDeleteParams = { + /** The ID of the chat report containing the track expense */ + chatReportID: string | undefined; + chatReport: OnyxEntry | undefined; + + /** The ID of the track expense being deleted */ + transactionID: string | undefined; + + /** The report action associated with the track expense */ + reportAction: OnyxTypes.ReportAction; + iouReport: OnyxEntry; + iouReportTransactions: OnyxTypes.Transaction[]; + chatIOUReport: OnyxEntry; + isChatReportArchived: boolean | undefined; + getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals']; + + /** Whether we're in single transaction view */ + isSingleTransactionView: boolean | undefined; + currentUserAccountID: number; +}; + /** * Calculate the URL to navigate to after a track expense deletion - * @param chatReportID - The ID of the chat report containing the track expense - * @param transactionID - The ID of the track expense being deleted - * @param reportAction - The report action associated with the track expense - * @param isSingleTransactionView - Whether we're in single transaction view * @returns The URL to navigate to */ -function getNavigationUrlAfterTrackExpenseDelete( - chatReportID: string | undefined, - chatReport: OnyxEntry | undefined, - transactionID: string | undefined, - reportAction: OnyxTypes.ReportAction, - iouReport: OnyxEntry, - iouReportTransactions: OnyxTypes.Transaction[], - chatIOUReport: OnyxEntry, - isChatReportArchived: boolean | undefined, - getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals'], - isSingleTransactionView: boolean | undefined, - currentUserAccountID: number, -): Route | undefined { +function getNavigationUrlAfterTrackExpenseDelete({ + chatReportID, + chatReport, + transactionID, + reportAction, + iouReport, + iouReportTransactions, + chatIOUReport, + isChatReportArchived, + getCurrencyDecimals, + isSingleTransactionView, + currentUserAccountID, +}: GetNavigationUrlAfterTrackExpenseDeleteParams): Route | undefined { if (!chatReportID || !transactionID) { return undefined; } @@ -3087,18 +3104,18 @@ function getNavigationUrlAfterTrackExpenseDelete( if (!isSelfDM(chatReport)) { const allReports = getAllReports(); const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportAction.childReportID}`]; - return getNavigationUrlOnMoneyRequestDelete( + return getNavigationUrlOnMoneyRequestDelete({ transactionID, reportAction, transactionThreadReport, iouReport, iouReportTransactions, - chatIOUReport, + chatReport: chatIOUReport, isChatReportArchived, getCurrencyDecimals, currentUserAccountID, isSingleTransactionView, - ); + }); } // Only navigate if in single transaction view and the thread will be deleted @@ -3135,7 +3152,7 @@ function deleteTrackExpense({ return; } - const urlToNavigateBack = getNavigationUrlAfterTrackExpenseDelete( + const urlToNavigateBack = getNavigationUrlAfterTrackExpenseDelete({ chatReportID, chatReport, transactionID, @@ -3143,11 +3160,11 @@ function deleteTrackExpense({ iouReport, iouReportTransactions, chatIOUReport, - isChatIOUReportArchived, + isChatReportArchived: isChatIOUReportArchived, getCurrencyDecimals, isSingleTransactionView, currentUserAccountID, - ); + }); const allReports = getAllReports(); const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportAction.childReportID}`]; diff --git a/src/pages/DynamicReportDetailsPage/hooks/useReportDetailsDeleteModal.ts b/src/pages/DynamicReportDetailsPage/hooks/useReportDetailsDeleteModal.ts index 2d8c8a21818a..2315487c1653 100644 --- a/src/pages/DynamicReportDetailsPage/hooks/useReportDetailsDeleteModal.ts +++ b/src/pages/DynamicReportDetailsPage/hooks/useReportDetailsDeleteModal.ts @@ -88,33 +88,33 @@ function useReportDetailsDeleteModal(reportID: string, caseID: CaseID, parentRep const isTrackExpense = isTrackExpenseAction(requestParentReportAction); if (isTrackExpense) { - urlToNavigateBack = getNavigationUrlAfterTrackExpenseDelete( - moneyRequestReport?.reportID, - moneyRequestReport, - iouTransactionID, - requestParentReportAction, + urlToNavigateBack = getNavigationUrlAfterTrackExpenseDelete({ + chatReportID: moneyRequestReport?.reportID, + chatReport: moneyRequestReport, + transactionID: iouTransactionID, + reportAction: requestParentReportAction, iouReport, iouReportTransactions, chatIOUReport, - isChatIOUReportArchived, + isChatReportArchived: isChatIOUReportArchived, getCurrencyDecimals, isSingleTransactionView, currentUserAccountID, - ); + }); } else { - urlToNavigateBack = getNavigationUrlOnMoneyRequestDelete( - iouTransactionID, - requestParentReportAction, - requestParentReportActionChildReport, + urlToNavigateBack = getNavigationUrlOnMoneyRequestDelete({ + transactionID: iouTransactionID, + reportAction: requestParentReportAction, + transactionThreadReport: requestParentReportActionChildReport, iouReport, iouReportTransactions, - chatIOUReport, - isChatIOUReportArchived, + chatReport: chatIOUReport, + isChatReportArchived: isChatIOUReportArchived, getCurrencyDecimals, currentUserAccountID, isSingleTransactionView, - chatIOUReportActions, - ); + chatReportActions: chatIOUReportActions, + }); } } diff --git a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts index 5b26e1d2fe9d..03c64e5c5397 100644 --- a/tests/actions/IOUTest/DeleteMoneyRequestTest.ts +++ b/tests/actions/IOUTest/DeleteMoneyRequestTest.ts @@ -563,7 +563,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => { reportID: iouReport.reportID, transactionThreadReport: thread, iouReport, - iouReportTransactions: [transaction], + iouReportTransactions: await getReportTransactionsFromOnyx(iouReport.reportID), chatReport, isChatIOUReportArchived: false, originalReportID: iouReport.reportID, @@ -2816,7 +2816,18 @@ describe('actions/IOU/DeleteMoneyRequest', () => { const getLastVisibleActionSpy = jest.spyOn(require('@libs/ReportActionsUtils'), 'getLastVisibleAction'); // When the navigation URL is calculated for the current user - getNavigationUrlOnMoneyRequestDelete(DELETED_TRANSACTION_ID, deletedIOUAction, undefined, iouReport, chatReport, false, getCurrencyDecimalsLocal, CURRENT_USER_ACCOUNT_ID, false); + getNavigationUrlOnMoneyRequestDelete({ + transactionID: DELETED_TRANSACTION_ID, + reportAction: deletedIOUAction, + transactionThreadReport: undefined, + iouReport, + iouReportTransactions: await getReportTransactionsFromOnyx(IOU_REPORT_ID), + chatReport, + isChatReportArchived: false, + getCurrencyDecimals: getCurrencyDecimalsLocal, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + isSingleTransactionView: false, + }); // Then the last visible action is resolved with that user's whisper visibility instead of the session fallback expect(getLastVisibleActionSpy).toHaveBeenCalledWith(IOU_REPORT_ID, expect.anything(), expect.anything(), undefined, undefined, CURRENT_USER_ACCOUNT_ID); From ed55555e5831f02ac0f2cf52b02e4977b85906e7 Mon Sep 17 00:00:00 2001 From: Linh Date: Mon, 16 Nov 2026 10:44:15 +0700 Subject: [PATCH 3/4] test: Seed the derived report transactions for the invoice delete test --- tests/ui/DynamicReportDetailsPageTest.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/ui/DynamicReportDetailsPageTest.tsx b/tests/ui/DynamicReportDetailsPageTest.tsx index ce58fbf623d7..593ce9328ee7 100644 --- a/tests/ui/DynamicReportDetailsPageTest.tsx +++ b/tests/ui/DynamicReportDetailsPageTest.tsx @@ -334,6 +334,8 @@ describe('DynamicReportDetailsPage', () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, transactionThreadReport); await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${invoiceReportID}`, {[iouActionID]: iouAction}); await Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, transaction); + // The page reads the invoice's transactions from the derived value, which this test doesn't compute, so seed it. + await Onyx.merge(ONYXKEYS.DERIVED.REPORT_TRANSACTIONS_AND_VIOLATIONS, {[invoiceReportID]: {transactions: {[transactionID]: transaction}, violations: {}}}); await Onyx.set(ONYXKEYS.IS_LOADING_REPORT_DATA, false); await Onyx.merge(`${ONYXKEYS.COLLECTION.RAM_ONLY_REPORT_LOADING_STATE}${invoiceReportID}`, {isLoadingInitialReportActions: false}); }); From 56ce7b730d26199ef85c273de23442e468dede3c Mon Sep 17 00:00:00 2001 From: Linh Date: Mon, 16 Nov 2026 10:50:14 +0700 Subject: [PATCH 4/4] chore: remove comment --- src/libs/actions/IOU/DeleteMoneyRequest.ts | 5 ----- src/libs/actions/IOU/TrackExpense.ts | 7 ------- 2 files changed, 12 deletions(-) diff --git a/src/libs/actions/IOU/DeleteMoneyRequest.ts b/src/libs/actions/IOU/DeleteMoneyRequest.ts index ca3564288b14..08d937a45540 100644 --- a/src/libs/actions/IOU/DeleteMoneyRequest.ts +++ b/src/libs/actions/IOU/DeleteMoneyRequest.ts @@ -346,10 +346,7 @@ function prepareToCleanUpMoneyRequest({ } type GetNavigationUrlOnMoneyRequestDeleteParams = { - /** The ID of the money request being deleted */ transactionID: string | undefined; - - /** The report action associated with the money request */ reportAction: OnyxTypes.ReportAction | undefined; transactionThreadReport: OnyxEntry; iouReport: OnyxEntry; @@ -358,8 +355,6 @@ type GetNavigationUrlOnMoneyRequestDeleteParams = { isChatReportArchived: boolean | undefined; getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals']; currentUserAccountID: number; - - /** Whether we are in the transaction thread report */ isSingleTransactionView?: boolean; chatReportActions?: OnyxEntry; }; diff --git a/src/libs/actions/IOU/TrackExpense.ts b/src/libs/actions/IOU/TrackExpense.ts index 989a62b4d9b6..2da9ff35019c 100644 --- a/src/libs/actions/IOU/TrackExpense.ts +++ b/src/libs/actions/IOU/TrackExpense.ts @@ -3059,22 +3059,15 @@ function trackExpense(params: CreateTrackExpenseParams) { } type GetNavigationUrlAfterTrackExpenseDeleteParams = { - /** The ID of the chat report containing the track expense */ chatReportID: string | undefined; chatReport: OnyxEntry | undefined; - - /** The ID of the track expense being deleted */ transactionID: string | undefined; - - /** The report action associated with the track expense */ reportAction: OnyxTypes.ReportAction; iouReport: OnyxEntry; iouReportTransactions: OnyxTypes.Transaction[]; chatIOUReport: OnyxEntry; isChatReportArchived: boolean | undefined; getCurrencyDecimals: CurrencyListActionsContextType['getCurrencyDecimals']; - - /** Whether we're in single transaction view */ isSingleTransactionView: boolean | undefined; currentUserAccountID: number; };