From 9c6f4c4f9bace23e650a630cd2a00030f1c75df6 Mon Sep 17 00:00:00 2001 From: X Developer Date: Mon, 3 Aug 2026 21:08:10 +0430 Subject: [PATCH 1/2] fix(report-history): show reimbursement's actual bank account instead of current workspace account --- src/libs/ReportNameUtils.ts | 2 +- .../report/actionContents/PaymentContent.tsx | 2 +- tests/ui/ReportActionItemTest.tsx | 50 ++++++++++++++++++- tests/unit/ReportNameUtilsTest.ts | 49 ++++++++++++++++++ 4 files changed, 100 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportNameUtils.ts b/src/libs/ReportNameUtils.ts index 53928281eae6..6f2970b33ae6 100644 --- a/src/libs/ReportNameUtils.ts +++ b/src/libs/ReportNameUtils.ts @@ -731,7 +731,7 @@ function computeReportNameBasedOnReportAction( if (isMoneyRequestAction(parentReportAction)) { const originalMessage = getOriginalMessage(parentReportAction); - const last4Digits = reportPolicy?.achAccount?.accountNumber?.slice(-4) ?? ''; + const last4Digits = originalMessage?.accountNumber?.slice(-4) ?? reportPolicy?.achAccount?.accountNumber?.slice(-4) ?? ''; if (originalMessage?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) { if (originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.ELSEWHERE) { diff --git a/src/pages/inbox/report/actionContents/PaymentContent.tsx b/src/pages/inbox/report/actionContents/PaymentContent.tsx index 7de016892c0a..9934ea5ebb78 100644 --- a/src/pages/inbox/report/actionContents/PaymentContent.tsx +++ b/src/pages/inbox/report/actionContents/PaymentContent.tsx @@ -39,7 +39,7 @@ function PaymentContent({action, policyID}: PaymentContentProps) { } if (paymentType === CONST.IOU.PAYMENT_TYPE.VBBA) { - const last4Digits = getBankAccountLastFourDigits(originalMessage.bankAccountID, bankAccountList, policy); + const last4Digits = originalMessage.accountNumber?.slice(-4) ?? getBankAccountLastFourDigits(originalMessage.bankAccountID, bankAccountList, policy); const crossBorderMessage = getCrossBorderReimbursedMessage(translate, originalMessage, last4Digits); if (wasAutoPaid) { const translation = crossBorderMessage ?? translate('iou.automaticallyPaidWithBusinessBankAccount', '', last4Digits); diff --git a/tests/ui/ReportActionItemTest.tsx b/tests/ui/ReportActionItemTest.tsx index 97aa17ba74e9..f667af0d0959 100644 --- a/tests/ui/ReportActionItemTest.tsx +++ b/tests/ui/ReportActionItemTest.tsx @@ -24,7 +24,7 @@ import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import * as ReportActionUtils from '@src/libs/ReportActionsUtils'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {ReportAction} from '@src/types/onyx'; +import type {Report, ReportAction} from '@src/types/onyx'; import type {OriginalMessage} from '@src/types/onyx/ReportAction'; import type ReportActionName from '@src/types/onyx/ReportActionName'; @@ -1943,6 +1943,54 @@ describe('ReportActionItem', () => { expect(screen.getByText(/paid with bank account/i)).toBeOnTheScreen(); }); + it('IOU PAY VBBA manual prefers originalMessage accountNumber over current policy account', async () => { + const policyID = 'snapshot-policy'; + await act(async () => { + await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, { + id: policyID, + achAccount: { + accountNumber: 'XXXX2222', + }, + }); + }); + await waitForBatchedUpdatesWithAct(); + + const action = createReportAction(CONST.REPORT.ACTIONS.TYPE.IOU, { + type: CONST.IOU.REPORT_ACTION_TYPE.PAY, + paymentType: CONST.IOU.PAYMENT_TYPE.VBBA, + automaticAction: false, + accountNumber: 'XXXX1111', + }); + const report = { + reportID: 'testReport', + ownerAccountID: ACTOR_ACCOUNT_ID, + policyID, + } as Report; + + render( + + + + + + + , + ); + await waitForBatchedUpdatesWithAct(); + + expect(screen.getByText(/1111/)).toBeOnTheScreen(); + expect(screen.queryByText(/2222/)).toBeNull(); + }); + it('IOU PAY VBBA automatic renders auto-paid message', async () => { await act(async () => { // eslint-disable-next-line @typescript-eslint/naming-convention diff --git a/tests/unit/ReportNameUtilsTest.ts b/tests/unit/ReportNameUtilsTest.ts index f26c2583a7e6..e271778d02d4 100644 --- a/tests/unit/ReportNameUtilsTest.ts +++ b/tests/unit/ReportNameUtilsTest.ts @@ -470,6 +470,55 @@ describe('ReportNameUtils', () => { ); expect(name).toBe(expected); }); + test('VBBA pay parent action uses action accountNumber before current policy account', () => { + const policyID = '123'; + const thread: Report = { + ...createWorkspaceThread(61), + policyID, + }; + const parentAction: ReportAction = { + actionName: CONST.REPORT.ACTIONS.TYPE.IOU, + reportActionID: String(thread.parentReportActionID), + message: [], + created: '', + lastModified: '', + actorAccountID: 1, + person: [], + originalMessage: { + type: CONST.IOU.REPORT_ACTION_TYPE.PAY, + paymentType: CONST.IOU.PAYMENT_TYPE.VBBA, + accountNumber: 'XXXX1111', + }, + }; + + const reportActionsCollection: Record = { + [`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${thread.parentReportID}`]: { + [String(thread.parentReportActionID)]: parentAction, + }, + }; + const policiesCollection: Record = { + [`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]: { + ...createRandomPolicy(Number(policyID), CONST.POLICY.TYPE.TEAM), + id: policyID, + achAccount: { + accountNumber: 'XXXX2222', + }, + }, + }; + + const name = computeReportName( + thread, + emptyCollections.reports, + policiesCollection, + undefined, + undefined, + participantsPersonalDetails, + reportActionsCollection, + currentUserAccountID, + ); + + expect(name).toBe(translate(CONST.LOCALES.EN, 'iou.businessBankAccount', undefined, '1111')); + }); test('Cross-border pay parent action', () => { // Given a thread on a payment that converted currency for the employee const thread: Report = createWorkspaceThread(60); From 7367bc3efb44f34d985cf6c2bf7259433e356107 Mon Sep 17 00:00:00 2001 From: X Developer Date: Tue, 4 Aug 2026 12:08:11 +0430 Subject: [PATCH 2/2] Fix ReportNameUtils ACH account test mock --- tests/unit/ReportNameUtilsTest.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/unit/ReportNameUtilsTest.ts b/tests/unit/ReportNameUtilsTest.ts index e271778d02d4..e5725fa148d9 100644 --- a/tests/unit/ReportNameUtilsTest.ts +++ b/tests/unit/ReportNameUtilsTest.ts @@ -501,7 +501,12 @@ describe('ReportNameUtils', () => { ...createRandomPolicy(Number(policyID), CONST.POLICY.TYPE.TEAM), id: policyID, achAccount: { + bankAccountID: 1, accountNumber: 'XXXX2222', + routingNumber: '', + addressName: '', + bankName: '', + reimburser: '', }, }, };