From 09760a80e4bc6e32c50970f1073f215279dd5145 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 21 Jul 2026 13:58:23 +0700 Subject: [PATCH 1/6] refactor: thread currentUserAccountID through getReportDisplayOption --- src/libs/OptionsListUtils/index.ts | 4 +++- src/pages/Share/ShareDetailsPage.tsx | 5 +++-- tests/unit/OptionsListUtilsTest.tsx | 28 ++++++++++++++-------------- tests/unit/ReportActionsUtilsTest.ts | 4 ++-- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 8dad17e3bd94..a1995a029991 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -1328,6 +1328,7 @@ function getReportDisplayOption( personalDetails: OnyxEntry, privateIsArchived: boolean | undefined, policy: OnyxEntry, + currentUserAccountID: number, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], policyTags?: OnyxEntry, visibleReportActionsData: VisibleReportActionsDerivedValue = {}, @@ -1346,7 +1347,8 @@ function getReportDisplayOption( }, reportAttributesDerived, policyTags, - visibleReportActionsData, + visibleReportActionsData: visibleReportActionsData ?? {}, + currentUserAccountID, }); // Update text & alternateText because createOption returns workspace name only if report is owned by the user diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index 64e23c563e9f..cf74120b85bc 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -81,9 +81,10 @@ function ShareDetailsPage({route}: ShareDetailsPageProps) { const privateIsArchived = useReportIsArchived(report?.reportID); const ancestors = useAncestors(report); const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`); + const currentUserAccountID = personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID; const displayReport = useMemo( - () => getReportDisplayOption(report, unknownUserDetails, personalDetails, privateIsArchived, policy, reportAttributesDerived), - [report, unknownUserDetails, personalDetails, privateIsArchived, reportAttributesDerived, policy], + () => getReportDisplayOption(report, unknownUserDetails, personalDetails, privateIsArchived, policy, currentUserAccountID, reportAttributesDerived), + [report, unknownUserDetails, personalDetails, privateIsArchived, policy, currentUserAccountID, reportAttributesDerived], ); const shouldShowAttachment = !isTextShared; diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index b596708228d0..ae01a62b2dc7 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -6336,7 +6336,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, undefined, personalDetails, undefined, undefined); + const result = getReportDisplayOption(report, undefined, personalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); // Then it should return an option with isSelfDM and alternateText set expect(result.isSelfDM).toBe(true); @@ -6356,7 +6356,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, undefined, personalDetails, undefined, undefined); + const result = getReportDisplayOption(report, undefined, personalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); // Then it should return an option with invoice room text and alternateText expect(result.isInvoiceRoom).toBe(true); @@ -6378,7 +6378,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, unknownUserDetails, personalDetails, undefined, undefined); + const result = getReportDisplayOption(report, unknownUserDetails, personalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); // Then it should return an option with unknownUserDetails data expect(result.text).toBe('Unknown User'); @@ -6399,7 +6399,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, undefined, personalDetails, undefined, undefined); + const result = getReportDisplayOption(report, undefined, personalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); // Then it should return an option with workspace name expect(result.text).toBe(POLICY.name); @@ -6428,7 +6428,7 @@ describe('OptionsListUtils', () => { }; // When we call getReportDisplayOption with custom personalDetails - const result = getReportDisplayOption(report, undefined, customPersonalDetails, undefined, undefined); + const result = getReportDisplayOption(report, undefined, customPersonalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); // Then it should use the custom personalDetails parameter expect(result).toBeDefined(); @@ -6445,7 +6445,7 @@ describe('OptionsListUtils', () => { const emptyPersonalDetails: PersonalDetailsList = {}; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, undefined, emptyPersonalDetails, undefined, undefined); + const result = getReportDisplayOption(report, undefined, emptyPersonalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); // Then it should not throw and return a valid option expect(result).toBeDefined(); @@ -6457,7 +6457,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption with undefined report - const result = getReportDisplayOption(undefined, undefined, personalDetails, undefined, undefined); + const result = getReportDisplayOption(undefined, undefined, personalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); // Then it should return a valid option (createOption handles undefined) expect(result).toBeDefined(); @@ -6898,7 +6898,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined); + const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -6921,7 +6921,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined); + const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -6941,7 +6941,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, undefined, undefined); + const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, undefined, undefined, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -6965,7 +6965,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined); + const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -6989,7 +6989,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined); + const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -8271,7 +8271,7 @@ describe('OptionsListUtils', () => { await waitForBatchedUpdates(); // When we call getReportDisplayOption with chat report - const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, undefined, undefined); + const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, undefined, undefined, CURRENT_USER_ACCOUNT_ID); // Then the option should be created successfully using the reports collection expect(option).toBeDefined(); @@ -8748,7 +8748,7 @@ describe('OptionsListUtils', () => { }, }; - const result = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, undefined, POLICY); + const result = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, undefined, POLICY, CURRENT_USER_ACCOUNT_ID); expect(result).toBeDefined(); expect(result.policyID).toBe(policyID); }); diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index 83e297edf3c9..baef3a3d8431 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -4802,7 +4802,7 @@ describe('ReportActionsUtils', () => { creditBankAccountLast4: '5678', }); - const result = ReportActionsUtils.getReimbursedMessage(translateLocal, action, 2, undefined, undefined); + const result = ReportActionsUtils.getReimbursedMessage(translateLocal, action, 2, undefined, undefined, 2); // Then the message shows the last 4 digits of the account that funded the payment const expected = `${translateLocal('iou.reimbursedThisReport')} ${translateLocal('iou.reimbursedFromBankAccount', '4321')}${translateLocal('iou.reimbursedWithACH', { @@ -4820,7 +4820,7 @@ describe('ReportActionsUtils', () => { creditBankAccountLast4: '5678', }); - const result = ReportActionsUtils.getReimbursedMessage(translateLocal, action, 2, undefined, undefined); + const result = ReportActionsUtils.getReimbursedMessage(translateLocal, action, 2, undefined, undefined, 2); expect(result).toBe( `${translateLocal('iou.reimbursedThisReport')} ${translateLocal('iou.reimbursedFromBankAccount', '9999')}${translateLocal('iou.reimbursedWithACH', { From ded096e1b7e484496b416d384ecd64cb82288c70 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 21 Jul 2026 14:10:47 +0700 Subject: [PATCH 2/6] refactor: thread currentUserAccountID through getPolicyExpenseReportOption --- src/libs/OptionsListUtils/index.ts | 22 +++++++++++++++++-- src/pages/iou/DynamicSplitBillDetailsPage.tsx | 10 ++++++++- .../request/MoneyRequestAttendeeSelector.tsx | 10 ++++++++- .../iou/request/ParticipantSearchResults.tsx | 10 ++++++++- tests/unit/OptionsListUtilsTest.tsx | 20 ++++++++--------- 5 files changed, 57 insertions(+), 15 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index a1995a029991..a8b4502a5416 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -1380,6 +1380,7 @@ function getPolicyExpenseReportOption( personalDetails: OnyxEntry, expenseReport: OnyxEntry, policy: OnyxEntry, + currentUserAccountID: number, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], policyTags?: OnyxEntry, visibleReportActionsData: VisibleReportActionsDerivedValue = {}, @@ -1401,6 +1402,7 @@ function getPolicyExpenseReportOption( reportAttributesDerived, policyTags, visibleReportActionsData, + currentUserAccountID, }); // Update text & alternateText because createOption returns workspace name only if report is owned by the user @@ -3013,7 +3015,15 @@ function formatSectionsFromSearchTerm( const expenseReport = getReportByID(participant.reportID); const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${expenseReport?.reportID}`]; const expenseReportPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${expenseReport?.policyID}`]; - return getPolicyExpenseReportOption(participant, privateIsArchived, personalDetails, expenseReport, expenseReportPolicy, reportAttributesDerived); + return getPolicyExpenseReportOption( + participant, + privateIsArchived, + personalDetails, + expenseReport, + expenseReportPolicy, + currentUserAccountID, + reportAttributesDerived, + ); } return getParticipantsOption(participant, personalDetails, translate); }) @@ -3045,7 +3055,15 @@ function formatSectionsFromSearchTerm( const expenseReport = getReportByID(participant.reportID); const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${expenseReport?.reportID}`]; const expenseReportPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${expenseReport?.policyID}`]; - return getPolicyExpenseReportOption(participant, privateIsArchived, personalDetails, expenseReport, expenseReportPolicy, reportAttributesDerived); + return getPolicyExpenseReportOption( + participant, + privateIsArchived, + personalDetails, + expenseReport, + expenseReportPolicy, + currentUserAccountID, + reportAttributesDerived, + ); } return getParticipantsOption(participant, personalDetails, translate); }) diff --git a/src/pages/iou/DynamicSplitBillDetailsPage.tsx b/src/pages/iou/DynamicSplitBillDetailsPage.tsx index e6285867e022..eb219b368e15 100644 --- a/src/pages/iou/DynamicSplitBillDetailsPage.tsx +++ b/src/pages/iou/DynamicSplitBillDetailsPage.tsx @@ -76,7 +76,15 @@ function DynamicSplitBillDetailsPage({report, reportAction}: SplitBillDetailsPag if (isPolicyExpenseChat(report)) { participants = [ getParticipantsOption({accountID: participantAccountIDs.at(0), selected: true, reportID: ''}, personalDetails, translate), - getPolicyExpenseReportOption({...report, selected: true, reportID}, privateIsArchived, personalDetails, report, policy, reportAttributesDerived), + getPolicyExpenseReportOption( + {...report, selected: true, reportID}, + privateIsArchived, + personalDetails, + report, + policy, + session?.accountID ?? CONST.DEFAULT_NUMBER_ID, + reportAttributesDerived, + ), ]; } else { participants = participantAccountIDs.map((accountID) => getParticipantsOption({accountID, selected: true, reportID: ''}, personalDetails, translate)); diff --git a/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx b/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx index 2e226d38e7fb..8377fb8a5490 100644 --- a/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx +++ b/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx @@ -269,7 +269,15 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde const isPolicyExpenseChat = participant?.isPolicyExpenseChat ?? false; const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${userToInviteExpenseReport?.reportID}`]; return isPolicyExpenseChat - ? getPolicyExpenseReportOption(participant, privateIsArchived, personalDetails, userToInviteExpenseReport, userToInviteExpenseReportPolicy, reportAttributesDerived) + ? getPolicyExpenseReportOption( + participant, + privateIsArchived, + personalDetails, + userToInviteExpenseReport, + userToInviteExpenseReportPolicy, + currentUserAccountID, + reportAttributesDerived, + ) : getParticipantsOption(participant, personalDetails, translate); }) as OptionData[], sectionIndex: 3, diff --git a/src/pages/iou/request/ParticipantSearchResults.tsx b/src/pages/iou/request/ParticipantSearchResults.tsx index b3f758c2555e..cc335a1b3cd2 100644 --- a/src/pages/iou/request/ParticipantSearchResults.tsx +++ b/src/pages/iou/request/ParticipantSearchResults.tsx @@ -369,7 +369,15 @@ function ParticipantSearchResults({ const isPolicyExpenseChat = participant?.isPolicyExpenseChat ?? false; const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${userToInviteExpenseReport?.reportID}`]; return isPolicyExpenseChat - ? getPolicyExpenseReportOption(participant, privateIsArchived, personalDetails, userToInviteExpenseReport, userToInviteExpenseReportPolicy, reportAttributesDerived) + ? getPolicyExpenseReportOption( + participant, + privateIsArchived, + personalDetails, + userToInviteExpenseReport, + userToInviteExpenseReportPolicy, + currentUserAccountID, + reportAttributesDerived, + ) : getParticipantsOption(participant, personalDetails, translate); }), sectionIndex: 5, diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index ae01a62b2dc7..468d2f6aa87c 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -7408,7 +7408,7 @@ describe('OptionsListUtils', () => { selected: true, }; - const option = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined); + const option = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.text).toBe('Test Workspace Policy'); @@ -7473,7 +7473,7 @@ describe('OptionsListUtils', () => { isPolicyExpenseChat: true, }; - const option = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined); + const option = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.text).toBe('Team Workspace'); @@ -7519,7 +7519,7 @@ describe('OptionsListUtils', () => { }; // Should not throw when personalDetails is empty - const option = getPolicyExpenseReportOption(participant, undefined, {}, report, undefined); + const option = getPolicyExpenseReportOption(participant, undefined, {}, report, undefined, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.text).toBe('Workspace Without Details'); @@ -7565,7 +7565,7 @@ describe('OptionsListUtils', () => { }; // Should not throw when personalDetails is undefined - const option = getPolicyExpenseReportOption(participant, undefined, undefined, report, undefined); + const option = getPolicyExpenseReportOption(participant, undefined, undefined, report, undefined, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.text).toBe('Workspace Undefined Details'); @@ -7619,10 +7619,10 @@ describe('OptionsListUtils', () => { selected: false, }; - const optionSelected = getPolicyExpenseReportOption(participantSelected, undefined, {}, report, undefined); + const optionSelected = getPolicyExpenseReportOption(participantSelected, undefined, {}, report, undefined, CURRENT_USER_ACCOUNT_ID); // eslint-disable-next-line rulesdir/no-negated-variables - const optionNotSelected = getPolicyExpenseReportOption(participantNotSelected, undefined, {}, report, undefined); + const optionNotSelected = getPolicyExpenseReportOption(participantNotSelected, undefined, {}, report, undefined, CURRENT_USER_ACCOUNT_ID); expect(optionSelected.isSelected).toBe(true); expect(optionSelected.selected).toBe(true); @@ -7680,7 +7680,7 @@ describe('OptionsListUtils', () => { selected: false, }; - const option = getPolicyExpenseReportOption(participant, true, testPersonalDetails, report, undefined); + const option = getPolicyExpenseReportOption(participant, true, testPersonalDetails, report, undefined, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.private_isArchived).toBe(true); @@ -7726,7 +7726,7 @@ describe('OptionsListUtils', () => { isPolicyExpenseChat: true, }; - const option = getPolicyExpenseReportOption(participant, undefined, {}, report, undefined); + const option = getPolicyExpenseReportOption(participant, undefined, {}, report, undefined, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option?.private_isArchived).toBeUndefined(); @@ -8312,7 +8312,7 @@ describe('OptionsListUtils', () => { }; // When we call getPolicyExpenseReportOption with report passed directly - const option = getPolicyExpenseReportOption(participant, undefined, PERSONAL_DETAILS, report, undefined); + const option = getPolicyExpenseReportOption(participant, undefined, PERSONAL_DETAILS, report, undefined, CURRENT_USER_ACCOUNT_ID); // Then the option should be created successfully expect(option).toBeDefined(); @@ -8777,7 +8777,7 @@ describe('OptionsListUtils', () => { selected: true, }; - const result = getPolicyExpenseReportOption(participant, undefined, PERSONAL_DETAILS, report, POLICY); + const result = getPolicyExpenseReportOption(participant, undefined, PERSONAL_DETAILS, report, POLICY, CURRENT_USER_ACCOUNT_ID); expect(result).toBeDefined(); expect(result.policyID).toBe(policyID); }); From f8881b0236516e7e6271b56d2658a00dc344ddfa Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 21 Jul 2026 14:18:22 +0700 Subject: [PATCH 3/6] add test --- tests/unit/OptionsListUtilsTest.tsx | 39 ++++++++++++++++++++++++++++ tests/unit/ReportActionsUtilsTest.ts | 36 +++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index 468d2f6aa87c..bd097bf75b47 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -7629,6 +7629,45 @@ describe('OptionsListUtils', () => { expect(optionNotSelected.isSelected).toBe(false); expect(optionNotSelected.selected).toBe(false); }); + + it('should return a valid option when called with different currentUserAccountID values', async () => { + const reportID = '210'; + const testPolicyID = 'policy210'; + const ownerAccountID = 1001; + + const report: Report = { + reportID, + reportName: 'Thread Test', + type: CONST.REPORT.TYPE.CHAT, + chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT, + policyID: testPolicyID, + ownerAccountID, + participants: { + [ownerAccountID]: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS}, + }, + }; + + const testPersonalDetails = { + [ownerAccountID]: { + accountID: ownerAccountID, + displayName: 'Policy Owner', + login: 'owner@test.com', + }, + }; + + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); + await waitForBatchedUpdates(); + + const participant = {reportID, policyID: testPolicyID, isPolicyExpenseChat: true, selected: true}; + + const optionWithCurrentUser = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined, CURRENT_USER_ACCOUNT_ID); + const optionWithDifferentUser = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined, 9999); + + expect(optionWithCurrentUser).toBeDefined(); + expect(optionWithDifferentUser).toBeDefined(); + expect(optionWithCurrentUser.reportID).toBe(reportID); + expect(optionWithDifferentUser.reportID).toBe(reportID); + }); }); describe('getPolicyExpenseReportOption with privateIsArchived', () => { diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts index baef3a3d8431..985fe11967f7 100644 --- a/tests/unit/ReportActionsUtilsTest.ts +++ b/tests/unit/ReportActionsUtilsTest.ts @@ -4829,6 +4829,42 @@ describe('ReportActionsUtils', () => { })}`, ); }); + + it('shows "your" wording for Fast_ACH when the current user is the report owner', () => { + const action = buildReimbursedAction({ + paymentMethod: 'Fast_ACH', + creditBankAccountLast4: '1111', + expectedDate: '2025-03-15', + }); + + const ownerAccountID = 42; + const submitterLogin = 'submitter@example.com'; + + const resultCurrentUser = ReportActionsUtils.getReimbursedMessage(translateLocal, action, ownerAccountID, submitterLogin, undefined, ownerAccountID); + expect(resultCurrentUser).toContain('your'); + expect(resultCurrentUser).not.toContain(submitterLogin); + + const resultOtherUser = ReportActionsUtils.getReimbursedMessage(translateLocal, action, ownerAccountID, submitterLogin, undefined, 999); + expect(resultOtherUser).toContain(submitterLogin); + expect(resultOtherUser).not.toContain('your'); + }); + + it('shows "your" wording for StripeConnect when the current user is the report owner', () => { + const action = buildReimbursedAction({ + paymentMethod: 'StripeConnect', + creditBankAccountLast4: '2222', + stripePaymentType: 'bank_transfer', + }); + + const ownerAccountID = 42; + const submitterLogin = 'submitter@example.com'; + + const resultCurrentUser = ReportActionsUtils.getReimbursedMessage(translateLocal, action, ownerAccountID, submitterLogin, undefined, ownerAccountID); + expect(resultCurrentUser).toContain('your'); + + const resultOtherUser = ReportActionsUtils.getReimbursedMessage(translateLocal, action, ownerAccountID, submitterLogin, undefined, 999); + expect(resultOtherUser).toContain(submitterLogin); + }); }); describe('getAutoReimbursementMessage', () => { From 11ee56f21908990f2084077d804cc613715038a6 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 21 Jul 2026 14:20:46 +0700 Subject: [PATCH 4/6] fix: revert redundant change --- src/libs/OptionsListUtils/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index a8b4502a5416..0cb3512410be 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -1347,7 +1347,7 @@ function getReportDisplayOption( }, reportAttributesDerived, policyTags, - visibleReportActionsData: visibleReportActionsData ?? {}, + visibleReportActionsData, currentUserAccountID, }); From 9a27419ca155a296abe7cad5eae58c7ed9bb4d9b Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 28 Jul 2026 15:02:02 +0700 Subject: [PATCH 5/6] fix: conflicts --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index a8a121b163e9..9f50d60a091f 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit a8a121b163e9e0b548a416511224c13483a08cd4 +Subproject commit 9f50d60a091f2610f91f7183ef7db3a66a21432c From 3eb8c5b93b928128d5c2246ec109627761fcc550 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 28 Jul 2026 17:07:21 +0700 Subject: [PATCH 6/6] fix: lint --- src/libs/OptionsListUtils/index.ts | 4 ++ src/pages/Share/ShareDetailsPage.tsx | 4 +- src/pages/iou/DynamicSplitBillDetailsPage.tsx | 1 + .../iou/request/ParticipantSearchResults.tsx | 1 + tests/unit/OptionsListUtilsTest.tsx | 54 +++++++++---------- 5 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index a68db98e6c07..a72cdec66fa3 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -1331,6 +1331,7 @@ function getReportDisplayOption( personalDetails: OnyxEntry, privateIsArchived: boolean | undefined, policy: OnyxEntry, + translate: LocalizedTranslate, currentUserAccountID: number, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], policyTags?: OnyxEntry, @@ -1383,6 +1384,7 @@ function getPolicyExpenseReportOption( personalDetails: OnyxEntry, expenseReport: OnyxEntry, policy: OnyxEntry, + translate: LocalizedTranslate, currentUserAccountID: number, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], policyTags?: OnyxEntry, @@ -3129,6 +3131,7 @@ function formatSectionsFromSearchTerm( personalDetails, expenseReport, expenseReportPolicy, + translate, currentUserAccountID, reportAttributesDerived, ); @@ -3169,6 +3172,7 @@ function formatSectionsFromSearchTerm( personalDetails, expenseReport, expenseReportPolicy, + translate, currentUserAccountID, reportAttributesDerived, ); diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index cf74120b85bc..b37ea0157301 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -83,8 +83,8 @@ function ShareDetailsPage({route}: ShareDetailsPageProps) { const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`); const currentUserAccountID = personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID; const displayReport = useMemo( - () => getReportDisplayOption(report, unknownUserDetails, personalDetails, privateIsArchived, policy, currentUserAccountID, reportAttributesDerived), - [report, unknownUserDetails, personalDetails, privateIsArchived, policy, currentUserAccountID, reportAttributesDerived], + () => getReportDisplayOption(report, unknownUserDetails, personalDetails, privateIsArchived, policy, translate, currentUserAccountID, reportAttributesDerived), + [report, unknownUserDetails, personalDetails, privateIsArchived, policy, currentUserAccountID, reportAttributesDerived, translate], ); const shouldShowAttachment = !isTextShared; diff --git a/src/pages/iou/DynamicSplitBillDetailsPage.tsx b/src/pages/iou/DynamicSplitBillDetailsPage.tsx index 7ab7d501905f..ac9abe51d85a 100644 --- a/src/pages/iou/DynamicSplitBillDetailsPage.tsx +++ b/src/pages/iou/DynamicSplitBillDetailsPage.tsx @@ -82,6 +82,7 @@ function DynamicSplitBillDetailsPage({report, reportAction}: SplitBillDetailsPag personalDetails, report, policy, + translate, session?.accountID ?? CONST.DEFAULT_NUMBER_ID, reportAttributesDerived, ), diff --git a/src/pages/iou/request/ParticipantSearchResults.tsx b/src/pages/iou/request/ParticipantSearchResults.tsx index cc335a1b3cd2..99f710cb07c7 100644 --- a/src/pages/iou/request/ParticipantSearchResults.tsx +++ b/src/pages/iou/request/ParticipantSearchResults.tsx @@ -375,6 +375,7 @@ function ParticipantSearchResults({ personalDetails, userToInviteExpenseReport, userToInviteExpenseReportPolicy, + translate, currentUserAccountID, reportAttributesDerived, ) diff --git a/tests/unit/OptionsListUtilsTest.tsx b/tests/unit/OptionsListUtilsTest.tsx index 8155a41c6bd3..3815a8a9727f 100644 --- a/tests/unit/OptionsListUtilsTest.tsx +++ b/tests/unit/OptionsListUtilsTest.tsx @@ -6356,7 +6356,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, undefined, personalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); + const result = getReportDisplayOption(report, undefined, personalDetails, undefined, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); // Then it should return an option with isSelfDM and alternateText set expect(result.isSelfDM).toBe(true); @@ -6376,7 +6376,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, undefined, personalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); + const result = getReportDisplayOption(report, undefined, personalDetails, undefined, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); // Then it should return an option with invoice room text and alternateText expect(result.isInvoiceRoom).toBe(true); @@ -6398,7 +6398,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, unknownUserDetails, personalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); + const result = getReportDisplayOption(report, unknownUserDetails, personalDetails, undefined, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); // Then it should return an option with unknownUserDetails data expect(result.text).toBe('Unknown User'); @@ -6419,7 +6419,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, undefined, personalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); + const result = getReportDisplayOption(report, undefined, personalDetails, undefined, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); // Then it should return an option with workspace name expect(result.text).toBe(POLICY.name); @@ -6448,7 +6448,7 @@ describe('OptionsListUtils', () => { }; // When we call getReportDisplayOption with custom personalDetails - const result = getReportDisplayOption(report, undefined, customPersonalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); + const result = getReportDisplayOption(report, undefined, customPersonalDetails, undefined, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); // Then it should use the custom personalDetails parameter expect(result).toBeDefined(); @@ -6465,7 +6465,7 @@ describe('OptionsListUtils', () => { const emptyPersonalDetails: PersonalDetailsList = {}; // When we call getReportDisplayOption - const result = getReportDisplayOption(report, undefined, emptyPersonalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); + const result = getReportDisplayOption(report, undefined, emptyPersonalDetails, undefined, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); // Then it should not throw and return a valid option expect(result).toBeDefined(); @@ -6477,7 +6477,7 @@ describe('OptionsListUtils', () => { const personalDetails: PersonalDetailsList = PERSONAL_DETAILS; // When we call getReportDisplayOption with undefined report - const result = getReportDisplayOption(undefined, undefined, personalDetails, undefined, undefined, CURRENT_USER_ACCOUNT_ID); + const result = getReportDisplayOption(undefined, undefined, personalDetails, undefined, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); // Then it should return a valid option (createOption handles undefined) expect(result).toBeDefined(); @@ -6917,7 +6917,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined, CURRENT_USER_ACCOUNT_ID); + const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -6940,7 +6940,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined, CURRENT_USER_ACCOUNT_ID); + const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -6960,7 +6960,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, undefined, undefined, CURRENT_USER_ACCOUNT_ID); + const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, undefined, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -6984,7 +6984,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined, CURRENT_USER_ACCOUNT_ID); + const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -7008,7 +7008,7 @@ describe('OptionsListUtils', () => { await Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, report); await waitForBatchedUpdates(); - const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined, CURRENT_USER_ACCOUNT_ID); + const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, !!reportNameValuePair?.private_isArchived, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.reportID).toBe(reportID); @@ -7427,7 +7427,7 @@ describe('OptionsListUtils', () => { selected: true, }; - const option = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined, CURRENT_USER_ACCOUNT_ID); + const option = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.text).toBe('Test Workspace Policy'); @@ -7454,7 +7454,7 @@ describe('OptionsListUtils', () => { const translateWithMarker: LocalizedTranslate = (path, ...parameters) => (path === 'workspace.common.workspace' ? 'WorkspaceMarker' : translateLocal(path, ...parameters)); const participant = {reportID, policyID: testPolicyID, isPolicyExpenseChat: true, selected: false}; - const option = getPolicyExpenseReportOption(participant, undefined, {}, report, undefined, translateWithMarker); + const option = getPolicyExpenseReportOption(participant, undefined, {}, report, undefined, translateWithMarker, CURRENT_USER_ACCOUNT_ID); // The subtitle resolves to the marker, proving the option builder used the injected translate (not translateLocal) expect(option.alternateText).toBe('WorkspaceMarker'); @@ -7517,7 +7517,7 @@ describe('OptionsListUtils', () => { isPolicyExpenseChat: true, }; - const option = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined, CURRENT_USER_ACCOUNT_ID); + const option = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.text).toBe('Team Workspace'); @@ -7563,7 +7563,7 @@ describe('OptionsListUtils', () => { }; // Should not throw when personalDetails is empty - const option = getPolicyExpenseReportOption(participant, undefined, {}, report, undefined, CURRENT_USER_ACCOUNT_ID); + const option = getPolicyExpenseReportOption(participant, undefined, {}, report, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.text).toBe('Workspace Without Details'); @@ -7609,7 +7609,7 @@ describe('OptionsListUtils', () => { }; // Should not throw when personalDetails is undefined - const option = getPolicyExpenseReportOption(participant, undefined, undefined, report, undefined, CURRENT_USER_ACCOUNT_ID); + const option = getPolicyExpenseReportOption(participant, undefined, undefined, report, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.text).toBe('Workspace Undefined Details'); @@ -7663,10 +7663,10 @@ describe('OptionsListUtils', () => { selected: false, }; - const optionSelected = getPolicyExpenseReportOption(participantSelected, undefined, {}, report, undefined, CURRENT_USER_ACCOUNT_ID); + const optionSelected = getPolicyExpenseReportOption(participantSelected, undefined, {}, report, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); // eslint-disable-next-line rulesdir/no-negated-variables - const optionNotSelected = getPolicyExpenseReportOption(participantNotSelected, undefined, {}, report, undefined, CURRENT_USER_ACCOUNT_ID); + const optionNotSelected = getPolicyExpenseReportOption(participantNotSelected, undefined, {}, report, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(optionSelected.isSelected).toBe(true); expect(optionSelected.selected).toBe(true); @@ -7704,8 +7704,8 @@ describe('OptionsListUtils', () => { const participant = {reportID, policyID: testPolicyID, isPolicyExpenseChat: true, selected: true}; - const optionWithCurrentUser = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined, CURRENT_USER_ACCOUNT_ID); - const optionWithDifferentUser = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined, 9999); + const optionWithCurrentUser = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); + const optionWithDifferentUser = getPolicyExpenseReportOption(participant, undefined, testPersonalDetails, report, undefined, translateLocal, 9999); expect(optionWithCurrentUser).toBeDefined(); expect(optionWithDifferentUser).toBeDefined(); @@ -7763,7 +7763,7 @@ describe('OptionsListUtils', () => { selected: false, }; - const option = getPolicyExpenseReportOption(participant, true, testPersonalDetails, report, undefined, CURRENT_USER_ACCOUNT_ID); + const option = getPolicyExpenseReportOption(participant, true, testPersonalDetails, report, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option.private_isArchived).toBe(true); @@ -7809,7 +7809,7 @@ describe('OptionsListUtils', () => { isPolicyExpenseChat: true, }; - const option = getPolicyExpenseReportOption(participant, undefined, {}, report, undefined, CURRENT_USER_ACCOUNT_ID); + const option = getPolicyExpenseReportOption(participant, undefined, {}, report, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(option).toBeDefined(); expect(option?.private_isArchived).toBeUndefined(); @@ -8354,7 +8354,7 @@ describe('OptionsListUtils', () => { await waitForBatchedUpdates(); // When we call getReportDisplayOption with chat report - const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, undefined, undefined, CURRENT_USER_ACCOUNT_ID); + const option = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, undefined, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); // Then the option should be created successfully using the reports collection expect(option).toBeDefined(); @@ -8395,7 +8395,7 @@ describe('OptionsListUtils', () => { }; // When we call getPolicyExpenseReportOption with report passed directly - const option = getPolicyExpenseReportOption(participant, undefined, PERSONAL_DETAILS, report, undefined, CURRENT_USER_ACCOUNT_ID); + const option = getPolicyExpenseReportOption(participant, undefined, PERSONAL_DETAILS, report, undefined, translateLocal, CURRENT_USER_ACCOUNT_ID); // Then the option should be created successfully expect(option).toBeDefined(); @@ -8808,7 +8808,7 @@ describe('OptionsListUtils', () => { }, }; - const result = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, undefined, POLICY, CURRENT_USER_ACCOUNT_ID); + const result = getReportDisplayOption(report, undefined, PERSONAL_DETAILS, undefined, POLICY, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(result).toBeDefined(); expect(result.policyID).toBe(policyID); }); @@ -8837,7 +8837,7 @@ describe('OptionsListUtils', () => { selected: true, }; - const result = getPolicyExpenseReportOption(participant, undefined, PERSONAL_DETAILS, report, POLICY, CURRENT_USER_ACCOUNT_ID); + const result = getPolicyExpenseReportOption(participant, undefined, PERSONAL_DETAILS, report, POLICY, translateLocal, CURRENT_USER_ACCOUNT_ID); expect(result).toBeDefined(); expect(result.policyID).toBe(policyID); });