diff --git a/src/libs/ReportNameUtils.ts b/src/libs/ReportNameUtils.ts
index e8b54650ddcd..85fe5ee0e42c 100644
--- a/src/libs/ReportNameUtils.ts
+++ b/src/libs/ReportNameUtils.ts
@@ -736,7 +736,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 3443313b7fcf..edf070cc486f 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 {BankAccountList, ReportAction} from '@src/types/onyx';
+import type {BankAccountList, Report, ReportAction} from '@src/types/onyx';
import type {OriginalMessage} from '@src/types/onyx/ReportAction';
import type ReportActionName from '@src/types/onyx/ReportActionName';
@@ -1949,6 +1949,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..e5725fa148d9 100644
--- a/tests/unit/ReportNameUtilsTest.ts
+++ b/tests/unit/ReportNameUtilsTest.ts
@@ -470,6 +470,60 @@ 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: {
+ bankAccountID: 1,
+ accountNumber: 'XXXX2222',
+ routingNumber: '',
+ addressName: '',
+ bankName: '',
+ reimburser: '',
+ },
+ },
+ };
+
+ 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);