From 86063b4a0d0cf61d855a10fb8ca87f4c0427b010 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sat, 28 Mar 2026 17:00:56 +0530 Subject: [PATCH 1/7] deprecate session data --- src/libs/actions/IOU/index.ts | 68 +++++++++++++++++------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index aec34197ebca5..23bf5a2b69571 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -982,13 +982,13 @@ Onyx.connect({ }, }); -let userAccountID = -1; -let currentUserEmail = ''; +let deprecatedUserAccountID = -1; +let deprecatedCurrentUserEmail = ''; Onyx.connect({ key: ONYXKEYS.SESSION, callback: (value) => { - currentUserEmail = value?.email ?? ''; - userAccountID = value?.accountID ?? CONST.DEFAULT_NUMBER_ID; + deprecatedCurrentUserEmail = value?.email ?? ''; + deprecatedUserAccountID = value?.accountID ?? CONST.DEFAULT_NUMBER_ID; }, }); @@ -996,7 +996,7 @@ let deprecatedCurrentUserPersonalDetails: OnyxEntry; Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (value) => { - deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined; + deprecatedCurrentUserPersonalDetails = value?.[deprecatedUserAccountID] ?? undefined; }, }); @@ -1046,11 +1046,11 @@ function getAllReportActionsFromIOU(): OnyxCollection { } function getCurrentUserEmail(): string { - return currentUserEmail; + return deprecatedCurrentUserEmail; } function getUserAccountID(): number { - return userAccountID; + return deprecatedUserAccountID; } /** @@ -1834,8 +1834,8 @@ function buildOnyxDataForTestDriveIOU( reportActionID: testDriveIOUParams.iouOptimisticParams.action.reportActionID, }); // eslint-disable-next-line @typescript-eslint/no-deprecated - const text = Localize.translateLocal('testDrive.employeeInviteMessage', personalDetailsList?.[userAccountID]?.firstName ?? ''); - const textComment = buildOptimisticAddCommentReportAction({text, actorAccountID: userAccountID, reportActionID: testDriveIOUParams.testDriveCommentReportActionID}); + const text = Localize.translateLocal('testDrive.employeeInviteMessage', personalDetailsList?.[deprecatedUserAccountID]?.firstName ?? ''); + const textComment = buildOptimisticAddCommentReportAction({text, actorAccountID: deprecatedUserAccountID, reportActionID: testDriveIOUParams.testDriveCommentReportActionID}); textComment.reportAction.created = DateUtils.subtractMillisecondsFromDateTime(testDriveIOUParams.iouOptimisticParams.createdAction.created, 1); optimisticData.push( @@ -3245,7 +3245,7 @@ function getMoneyRequestInformation(moneyRequestInformation: MoneyRequestInforma personalDetails, betas, } = moneyRequestInformation; - const {payeeAccountID = userAccountID, payeeEmail = currentUserEmail, participant} = participantParams; + const {payeeAccountID = deprecatedUserAccountID, payeeEmail = deprecatedCurrentUserEmail, participant} = participantParams; const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; const { attendees, @@ -3680,7 +3680,7 @@ function getTrackExpenseInformation(params: GetTrackExpenseInformationParams): T betas, isSelfTourViewed, } = params; - const {payeeAccountID = userAccountID, payeeEmail = currentUserEmail, participant} = participantParams; + const {payeeAccountID = deprecatedUserAccountID, payeeEmail = deprecatedCurrentUserEmail, participant} = participantParams; const {policy} = policyParams; const { comment, @@ -3726,7 +3726,7 @@ function getTrackExpenseInformation(params: GetTrackExpenseInformationParams): T if (!chatReport) { const currentTime = DateUtils.getDBTime(); const selfDMReport = buildOptimisticSelfDMReport(currentTime); - const selfDMCreatedReportAction = buildOptimisticCreatedReportAction(currentUserEmail ?? '', currentTime); + const selfDMCreatedReportAction = buildOptimisticCreatedReportAction(deprecatedCurrentUserEmail ?? '', currentTime); optimisticReportID = selfDMReport.reportID; optimisticReportActionID = selfDMCreatedReportAction.reportActionID; chatReport = selfDMReport; @@ -5973,7 +5973,7 @@ function convertBulkTrackedExpensesToIOU({ return; } - const participantAccountIDs = getReportRecipientAccountIDs(iouReport, userAccountID); + const participantAccountIDs = getReportRecipientAccountIDs(iouReport, deprecatedUserAccountID); const payerAccountID = participantAccountIDs.at(0); if (!payerAccountID) { @@ -6029,8 +6029,8 @@ function convertBulkTrackedExpensesToIOU({ } const participantParams = { - payeeAccountID: userAccountID, - payeeEmail: currentUserEmail, + payeeAccountID: deprecatedUserAccountID, + payeeEmail: deprecatedCurrentUserEmail, participant: { accountID: payerAccountID, login: payerEmail, @@ -6181,7 +6181,7 @@ function categorizeTrackedExpense(trackedExpenseParams: TrackedExpenseParams) { // If a draft policy was used, then the CategorizeTrackedExpense command will create a real one // so let's track that conversion here if (isDraftPolicy) { - GoogleTagManager.publishEvent(CONST.ANALYTICS.EVENT.WORKSPACE_CREATED, userAccountID); + GoogleTagManager.publishEvent(CONST.ANALYTICS.EVENT.WORKSPACE_CREATED, deprecatedUserAccountID); } } @@ -7522,7 +7522,7 @@ function createSplitsAndOnyxData({ personalDetailListAction: oneOnOnePersonalDetailListAction, }, currentUserAccountIDParam: currentUserAccountID, - currentUserEmailParam: currentUserEmail, + currentUserEmailParam: deprecatedCurrentUserEmail, hasViolations, quickAction, personalDetails, @@ -7736,8 +7736,8 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest moneyRequestReportID, participantParams: { participant, - payeeAccountID: userAccountID, - payeeEmail: currentUserEmail, + payeeAccountID: deprecatedUserAccountID, + payeeEmail: deprecatedCurrentUserEmail, }, policyParams: { policy, @@ -8444,7 +8444,7 @@ function getCleanUpTransactionThreadReportOnyxData({ stateNum: CONST.REPORT.STATE_NUM.APPROVED, statusNum: CONST.REPORT.STATUS_NUM.CLOSED, participants: { - [userAccountID]: { + [deprecatedUserAccountID]: { notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, }, }, @@ -8649,7 +8649,7 @@ function deleteMoneyRequest({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`, value: { - hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, updatedIOUReport, currentUserEmail, currentUserAccountID, allTransactionViolationsParam, undefined), + hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, updatedIOUReport, deprecatedCurrentUserEmail, currentUserAccountID, allTransactionViolationsParam, undefined), }, }); } @@ -8668,7 +8668,7 @@ function deleteMoneyRequest({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`, value: { - hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport?.reportID, currentUserEmail, currentUserAccountID, allTransactionViolationsParam, undefined), + hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport?.reportID, deprecatedCurrentUserEmail, currentUserAccountID, allTransactionViolationsParam, undefined), iouReportID: null, ...optimisticLastReportData, }, @@ -9399,7 +9399,7 @@ function getPayMoneyRequestParams({ successData: policySuccessData, params, } = buildPolicyData({ - policyOwnerEmail: currentUserEmail, + policyOwnerEmail: deprecatedCurrentUserEmail, makeMeAdmin: true, policyID: payerPolicyID, currentUserAccountIDParam: currentUserAccountIDParam ?? CONST.DEFAULT_NUMBER_ID, @@ -9473,7 +9473,7 @@ function getPayMoneyRequestParams({ const optimisticChatReport = { ...chatReport, lastReadTime: DateUtils.getDBTime(), - hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport?.reportID, currentUserEmail, currentUserAccountIDParam, allTransactionViolations, undefined), + hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport?.reportID, deprecatedCurrentUserEmail, currentUserAccountIDParam, allTransactionViolations, undefined), iouReportID: null, lastMessageText: getReportActionText(optimisticIOUReportAction), lastMessageHtml: getReportActionHtml(optimisticIOUReportAction), @@ -9721,7 +9721,7 @@ function canApproveIOU( } const managerID = iouReport?.managerID ?? CONST.DEFAULT_NUMBER_ID; - const isCurrentUserManager = managerID === userAccountID; + const isCurrentUserManager = managerID === deprecatedUserAccountID; const isOpenExpenseReport = isOpenExpenseReportReportUtils(iouReport); const isApproved = isReportApproved({report: iouReport}); const iouSettled = isSettled(iouReport); @@ -9781,12 +9781,12 @@ function canIOUBePaid( return false; } if (chatReport?.invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL) { - return chatReport?.invoiceReceiver?.accountID === userAccountID; + return chatReport?.invoiceReceiver?.accountID === deprecatedUserAccountID; } return invoiceReceiverPolicy?.role === CONST.POLICY.ROLE.ADMIN; } - const isPayer = isPayerReportUtils(userAccountID, currentUserEmail, iouReport, bankAccountList, policy, onlyShowPayElsewhere); + const isPayer = isPayerReportUtils(deprecatedUserAccountID, deprecatedCurrentUserEmail, iouReport, bankAccountList, policy, onlyShowPayElsewhere); const {reimbursableSpend} = getMoneyRequestSpendBreakdown(iouReport); const isAutoReimbursable = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES ? false : canBeAutoReimbursed(iouReport, policy); @@ -9880,8 +9880,8 @@ function getIOUReportActionWithBadge( policy, getReportTransactions(iouReport?.reportID), allTransactionViolations, - currentUserEmail, - userAccountID, + deprecatedCurrentUserEmail, + deprecatedUserAccountID, getAllReportActions(iouReport?.reportID), ); if (isWaitingSubmitFromCurrentUser) { @@ -11309,7 +11309,7 @@ function completePaymentOnboarding( return; } - const personalDetailsListValues = Object.values(getPersonalDetailsForAccountIDs(userAccountID ? [userAccountID] : [], personalDetailsList)); + const personalDetailsListValues = Object.values(getPersonalDetailsForAccountIDs(deprecatedUserAccountID ? [deprecatedUserAccountID] : [], personalDetailsList)); const personalDetails = personalDetailsListValues.at(0); let onboardingPurpose = introSelected?.choice; @@ -11936,7 +11936,7 @@ function shouldOptimisticallyUpdateSearch( return false; } - const suggestedSearches = getSuggestedSearches(userAccountID); + const suggestedSearches = getSuggestedSearches(deprecatedUserAccountID); const submitQueryJSON = suggestedSearches[CONST.SEARCH.SEARCH_KEYS.SUBMIT].searchQueryJSON; const approveQueryJSON = suggestedSearches[CONST.SEARCH.SEARCH_KEYS.APPROVE].searchQueryJSON; const unapprovedCashSimilarSearchHash = suggestedSearches[CONST.SEARCH.SEARCH_KEYS.UNAPPROVED_CASH].similarSearchHash; @@ -12458,7 +12458,7 @@ function prepareRejectMoneyRequestData( amount: transactionAmount, currency: getCurrency(transaction), comment, - payeeEmail: currentUserEmail, + payeeEmail: deprecatedCurrentUserEmail, participants: [{accountID: report?.ownerAccountID}], transactionID: transaction.transactionID, existingTransactionThreadReportID: childReportID, @@ -12720,7 +12720,7 @@ function prepareRejectMoneyRequestData( const shouldHaveOutstandingChildRequest = hasOutstandingChildRequest( policyExpenseChat, excludedReportID, - currentUserEmail, + deprecatedCurrentUserEmail, currentUserAccountIDParam, allTransactionViolations, undefined, @@ -12780,7 +12780,7 @@ function prepareRejectMoneyRequestData( type: CONST.VIOLATION_TYPES.WARNING, data: { comment: comment ?? '', - rejectedBy: currentUserEmail, + rejectedBy: deprecatedCurrentUserEmail, rejectedDate: DateUtils.getDBTime(), }, showInReview: true, From 792935f7ba84aaa1b96ba3b351b9593491403b67 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sat, 28 Mar 2026 17:07:43 +0530 Subject: [PATCH 2/7] Refactor getCleanUpTransactionThreadReportOnyxData --- src/libs/actions/IOU/Duplicate.ts | 2 ++ src/libs/actions/IOU/index.ts | 7 +++++-- src/libs/actions/MergeTransaction.ts | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/IOU/Duplicate.ts b/src/libs/actions/IOU/Duplicate.ts index c82992e02772f..67687fc7d542f 100644 --- a/src/libs/actions/IOU/Duplicate.ts +++ b/src/libs/actions/IOU/Duplicate.ts @@ -79,6 +79,7 @@ function mergeDuplicates({transactionThreadReportID: optimisticTransactionThread const allTransactionViolations = getAllTransactionViolations(); const allReports = getAllReports(); const currentUserEmail = getCurrentUserEmail(); + const currentUserAccountID = getUserAccountID(); const originalSelectedTransaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${params.transactionID}`]; @@ -221,6 +222,7 @@ function mergeDuplicates({transactionThreadReportID: optimisticTransactionThread reportAction: iouAction, updatedReportPreviewAction, shouldAddUpdatedReportPreviewActionToOnyxData: Number(index) === iouActionsToDelete.length - 1, + currentUserAccountID: currentUserAccountID, }); cleanUpTransactionThreadReportsOptimisticData.push(...cleanUpTransactionThreadReportOnyxDataForIouAction.optimisticData); cleanUpTransactionThreadReportsSuccessData.push(...cleanUpTransactionThreadReportOnyxDataForIouAction.successData); diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index 23bf5a2b69571..ad3886ff95bdc 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -3072,6 +3072,7 @@ function getDeleteTrackExpenseInformation( const cleanUpTransactionThreadReportOnyxData = getCleanUpTransactionThreadReportOnyxData({ transactionThreadID, shouldDeleteTransactionThread, + currentUserAccountID: deprecatedUserAccountID, }); optimisticData.push(...cleanUpTransactionThreadReportOnyxData.optimisticData); @@ -8413,6 +8414,7 @@ function getCleanUpTransactionThreadReportOnyxData({ isChatIOUReportArchived, updatedReportPreviewAction, shouldAddUpdatedReportPreviewActionToOnyxData = true, + currentUserAccountID, }: { transactionThreadID?: string; shouldDeleteTransactionThread: boolean; @@ -8420,6 +8422,7 @@ function getCleanUpTransactionThreadReportOnyxData({ isChatIOUReportArchived?: boolean; updatedReportPreviewAction?: ReportAction; shouldAddUpdatedReportPreviewActionToOnyxData?: boolean; + currentUserAccountID: number; }) { const optimisticData: Array> = []; const successData: Array> = []; @@ -8444,7 +8447,7 @@ function getCleanUpTransactionThreadReportOnyxData({ stateNum: CONST.REPORT.STATE_NUM.APPROVED, statusNum: CONST.REPORT.STATUS_NUM.CLOSED, participants: { - [deprecatedUserAccountID]: { + [currentUserAccountID]: { notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, }, }, @@ -8686,7 +8689,7 @@ function deleteMoneyRequest({ }); } - const cleanUpTransactionThreadReportOnyxData = getCleanUpTransactionThreadReportOnyxData({shouldDeleteTransactionThread, transactionThreadID, reportAction, isChatIOUReportArchived}); + const cleanUpTransactionThreadReportOnyxData = getCleanUpTransactionThreadReportOnyxData({shouldDeleteTransactionThread, transactionThreadID, reportAction, isChatIOUReportArchived, currentUserAccountID}); optimisticData.push(...cleanUpTransactionThreadReportOnyxData.optimisticData); const successData: Array> = [ diff --git a/src/libs/actions/MergeTransaction.ts b/src/libs/actions/MergeTransaction.ts index 0159bcb3cd564..6891f35fa083d 100644 --- a/src/libs/actions/MergeTransaction.ts +++ b/src/libs/actions/MergeTransaction.ts @@ -471,6 +471,7 @@ function mergeTransactionRequest({ transactionThreadID: sourceTransactionThreadReportID, shouldDeleteTransactionThread, reportAction: sourceIouAction, + currentUserAccountID: currentUserAccountIDParam, }); optimisticSourceReportActionData.push(...cleanUpSourceTransactionThreadReportOnyxData.optimisticData); successSourceReportActionData.push(...cleanUpSourceTransactionThreadReportOnyxData.successData); From 656e7ee07b9aae79b5241a29ecbd2b7b3965da91 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sat, 28 Mar 2026 17:10:12 +0530 Subject: [PATCH 3/7] Fix lint --- src/libs/actions/IOU/index.ts | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index ad3886ff95bdc..dbff6fb297f39 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -8652,7 +8652,14 @@ function deleteMoneyRequest({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`, value: { - hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, updatedIOUReport, deprecatedCurrentUserEmail, currentUserAccountID, allTransactionViolationsParam, undefined), + hasOutstandingChildRequest: hasOutstandingChildRequest( + chatReport, + updatedIOUReport, + deprecatedCurrentUserEmail, + currentUserAccountID, + allTransactionViolationsParam, + undefined, + ), }, }); } @@ -8671,7 +8678,14 @@ function deleteMoneyRequest({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`, value: { - hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport?.reportID, deprecatedCurrentUserEmail, currentUserAccountID, allTransactionViolationsParam, undefined), + hasOutstandingChildRequest: hasOutstandingChildRequest( + chatReport, + iouReport?.reportID, + deprecatedCurrentUserEmail, + currentUserAccountID, + allTransactionViolationsParam, + undefined, + ), iouReportID: null, ...optimisticLastReportData, }, @@ -8689,7 +8703,13 @@ function deleteMoneyRequest({ }); } - const cleanUpTransactionThreadReportOnyxData = getCleanUpTransactionThreadReportOnyxData({shouldDeleteTransactionThread, transactionThreadID, reportAction, isChatIOUReportArchived, currentUserAccountID}); + const cleanUpTransactionThreadReportOnyxData = getCleanUpTransactionThreadReportOnyxData({ + shouldDeleteTransactionThread, + transactionThreadID, + reportAction, + isChatIOUReportArchived, + currentUserAccountID, + }); optimisticData.push(...cleanUpTransactionThreadReportOnyxData.optimisticData); const successData: Array> = [ From fffc25ac9cf7922934c1e9d198e93cb1cdaf255e Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sat, 28 Mar 2026 17:10:51 +0530 Subject: [PATCH 4/7] cleanup --- src/libs/actions/IOU/Duplicate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU/Duplicate.ts b/src/libs/actions/IOU/Duplicate.ts index 67687fc7d542f..b6d91637f6da6 100644 --- a/src/libs/actions/IOU/Duplicate.ts +++ b/src/libs/actions/IOU/Duplicate.ts @@ -222,7 +222,7 @@ function mergeDuplicates({transactionThreadReportID: optimisticTransactionThread reportAction: iouAction, updatedReportPreviewAction, shouldAddUpdatedReportPreviewActionToOnyxData: Number(index) === iouActionsToDelete.length - 1, - currentUserAccountID: currentUserAccountID, + currentUserAccountID, }); cleanUpTransactionThreadReportsOptimisticData.push(...cleanUpTransactionThreadReportOnyxDataForIouAction.optimisticData); cleanUpTransactionThreadReportsSuccessData.push(...cleanUpTransactionThreadReportOnyxDataForIouAction.successData); From 0cee92bec5c30f122c1cd2d0be2384bdd4a10162 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sat, 28 Mar 2026 17:18:31 +0530 Subject: [PATCH 5/7] Update `deleteMoneyRequest` to pass currentuseremail --- src/hooks/useDeleteTransactions.ts | 1 + src/libs/actions/IOU/index.ts | 7 +++++-- src/libs/actions/Search.ts | 1 + tests/actions/IOUTest.ts | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/hooks/useDeleteTransactions.ts b/src/hooks/useDeleteTransactions.ts index 3706144844f4c..f9d46afdf8c69 100644 --- a/src/hooks/useDeleteTransactions.ts +++ b/src/hooks/useDeleteTransactions.ts @@ -192,6 +192,7 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac selectedTransactionIDs: transactionIDs, allTransactionViolationsParam: transactionViolations, currentUserAccountID: currentUserPersonalDetails.accountID, + currentUserEmail: currentUserPersonalDetails.email ?? '', }); deletedTransactionIDs.push(transactionID); if (action.childReportID) { diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index dbff6fb297f39..5c54d968ebc38 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -862,6 +862,7 @@ type DeleteMoneyRequestFunctionParams = { selectedTransactionIDs?: string[]; allTransactionViolationsParam: OnyxCollection; currentUserAccountID: number; + currentUserEmail: string; }; type PayMoneyRequestFunctionParams = { @@ -8569,6 +8570,7 @@ function deleteMoneyRequest({ selectedTransactionIDs, allTransactionViolationsParam, currentUserAccountID, + currentUserEmail, }: DeleteMoneyRequestFunctionParams) { if (!transactionID) { return; @@ -8655,7 +8657,7 @@ function deleteMoneyRequest({ hasOutstandingChildRequest: hasOutstandingChildRequest( chatReport, updatedIOUReport, - deprecatedCurrentUserEmail, + currentUserEmail, currentUserAccountID, allTransactionViolationsParam, undefined, @@ -8681,7 +8683,7 @@ function deleteMoneyRequest({ hasOutstandingChildRequest: hasOutstandingChildRequest( chatReport, iouReport?.reportID, - deprecatedCurrentUserEmail, + currentUserEmail, currentUserAccountID, allTransactionViolationsParam, undefined, @@ -8897,6 +8899,7 @@ function deleteTrackExpense({ isSingleTransactionView, allTransactionViolationsParam, currentUserAccountID, + currentUserEmail: deprecatedCurrentUserEmail, }); return urlToNavigateBack; } diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 1838aae73a576..1748f71fdd2e9 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -937,6 +937,7 @@ function bulkDeleteReports({ selectedTransactionIDs: batchTransactionIDsForReport.length > 0 ? batchTransactionIDsForReport : undefined, allTransactionViolationsParam: transactionsViolations, currentUserAccountID: currentUserAccountIDParam, + currentUserEmail: currentUserEmailParam, }); } diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index dd84a38cc8b15..0eba6538f6079 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -7721,6 +7721,7 @@ describe('actions/IOU', () => { isChatIOUReportArchived: true, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); } await waitForBatchedUpdates(); @@ -7810,6 +7811,7 @@ describe('actions/IOU', () => { isChatIOUReportArchived: true, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); } await waitForBatchedUpdates(); @@ -7892,6 +7894,7 @@ describe('actions/IOU', () => { chatReport, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); } await waitForBatchedUpdates(); @@ -8002,6 +8005,7 @@ describe('actions/IOU', () => { chatReport, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); } await waitForBatchedUpdates(); @@ -8149,6 +8153,7 @@ describe('actions/IOU', () => { chatReport, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); } await waitForBatchedUpdates(); @@ -8261,6 +8266,7 @@ describe('actions/IOU', () => { chatReport, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); } await waitForBatchedUpdates(); @@ -8446,6 +8452,7 @@ describe('actions/IOU', () => { isChatIOUReportArchived: undefined, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); } await waitForBatchedUpdates(); @@ -8559,6 +8566,7 @@ describe('actions/IOU', () => { isChatIOUReportArchived: undefined, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); } await waitForBatchedUpdates(); @@ -8662,6 +8670,7 @@ describe('actions/IOU', () => { isSingleTransactionView: true, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); } @@ -8719,6 +8728,7 @@ describe('actions/IOU', () => { chatReport, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); } // Then we expect to navigate to the chat report @@ -8882,6 +8892,7 @@ describe('actions/IOU', () => { chatReport, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); } @@ -9210,6 +9221,7 @@ describe('actions/IOU', () => { describe('bulk deleteMoneyRequest', () => { const TEST_USER_ACCOUNT_ID = 1; + const TEST_USER_LOGIN = 'test@email.com'; it('update IOU report total properly for bulk deletion of expenses', async () => { const expenseReport: Report = { @@ -9274,6 +9286,7 @@ describe('actions/IOU', () => { selectedTransactionIDs, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); deleteMoneyRequest({ transactionID: transaction2.transactionID, @@ -9286,6 +9299,7 @@ describe('actions/IOU', () => { selectedTransactionIDs, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); await waitForBatchedUpdates(); @@ -9307,6 +9321,7 @@ describe('actions/IOU', () => { describe('deleteMoneyRequest with allTransactionViolationsParam', () => { const TEST_USER_ACCOUNT_ID = 1; + const TEST_USER_LOGIN = 'test@email.com'; it('should pass transaction violations to hasOutstandingChildRequest correctly', async () => { // Given an expense report with a transaction const expenseReport: Report = { @@ -9361,6 +9376,7 @@ describe('actions/IOU', () => { chatReport: expenseReport, allTransactionViolationsParam: transactionViolations, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); await waitForBatchedUpdates(); @@ -9424,6 +9440,7 @@ describe('actions/IOU', () => { chatReport: expenseReport, allTransactionViolationsParam: {}, currentUserAccountID: TEST_USER_ACCOUNT_ID, + currentUserEmail: TEST_USER_LOGIN, }); await waitForBatchedUpdates(); From 80aee86a026b85390c9b84abfa7ca12aa665cc3a Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sat, 28 Mar 2026 17:23:28 +0530 Subject: [PATCH 6/7] fix --- src/libs/actions/IOU/index.ts | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index 5c54d968ebc38..c23a2427aa28a 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -8654,14 +8654,7 @@ function deleteMoneyRequest({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`, value: { - hasOutstandingChildRequest: hasOutstandingChildRequest( - chatReport, - updatedIOUReport, - currentUserEmail, - currentUserAccountID, - allTransactionViolationsParam, - undefined, - ), + hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, updatedIOUReport, currentUserEmail, currentUserAccountID, allTransactionViolationsParam, undefined), }, }); } @@ -8680,14 +8673,7 @@ function deleteMoneyRequest({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`, value: { - hasOutstandingChildRequest: hasOutstandingChildRequest( - chatReport, - iouReport?.reportID, - currentUserEmail, - currentUserAccountID, - allTransactionViolationsParam, - undefined, - ), + hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport?.reportID, currentUserEmail, currentUserAccountID, allTransactionViolationsParam, undefined), iouReportID: null, ...optimisticLastReportData, }, From b38b4212c3af4d44945cbef50f047fbcadb6a157 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sat, 28 Mar 2026 17:36:29 +0530 Subject: [PATCH 7/7] Refactor `deleteTrackExpense` --- src/libs/actions/IOU/index.ts | 4 +++- src/pages/ReportDetailsPage.tsx | 1 + .../report/ContextMenu/PopoverReportActionContextMenu.tsx | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index c23a2427aa28a..4411401e9452d 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -847,6 +847,7 @@ type DeleteTrackExpenseParams = { isChatIOUReportArchived: boolean | undefined; allTransactionViolationsParam: OnyxCollection; currentUserAccountID: number; + currentUserEmail: string; }; type DeleteMoneyRequestFunctionParams = { @@ -8856,6 +8857,7 @@ function deleteTrackExpense({ isChatIOUReportArchived, allTransactionViolationsParam, currentUserAccountID, + currentUserEmail, }: DeleteTrackExpenseParams) { if (!chatReportID || !transactionID) { return; @@ -8885,7 +8887,7 @@ function deleteTrackExpense({ isSingleTransactionView, allTransactionViolationsParam, currentUserAccountID, - currentUserEmail: deprecatedCurrentUserEmail, + currentUserEmail, }); return urlToNavigateBack; } diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index a3e94572702d3..e79d7568bd1a9 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -912,6 +912,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail isChatIOUReportArchived, allTransactionViolationsParam: allTransactionViolations, currentUserAccountID: currentUserPersonalDetails.accountID, + currentUserEmail: currentUserPersonalDetails.email ?? '', }); } else if (iouTransactionID) { deleteTransactions([iouTransactionID], duplicateTransactions, duplicateTransactionViolations, currentSearchHash, isSingleTransactionView); diff --git a/src/pages/inbox/report/ContextMenu/PopoverReportActionContextMenu.tsx b/src/pages/inbox/report/ContextMenu/PopoverReportActionContextMenu.tsx index 349a77f4d4df7..1af93caf52327 100644 --- a/src/pages/inbox/report/ContextMenu/PopoverReportActionContextMenu.tsx +++ b/src/pages/inbox/report/ContextMenu/PopoverReportActionContextMenu.tsx @@ -369,6 +369,7 @@ function PopoverReportActionContextMenu({ref}: PopoverReportActionContextMenuPro isChatIOUReportArchived, allTransactionViolationsParam: allTransactionViolations, currentUserAccountID, + currentUserEmail: email ?? '', }); } else if (originalMessage?.IOUTransactionID) { deleteTransactions([originalMessage.IOUTransactionID], duplicateTransactions, duplicateTransactionViolations, currentSearchHash);