From 75e5c5c20145660d45482096c90501038fbbc3a0 Mon Sep 17 00:00:00 2001 From: Mohammad Jafarinejad <71210799+mohammadjafarinejad@users.noreply.github.com> Date: Thu, 23 Oct 2025 03:56:19 +0400 Subject: [PATCH 1/5] fix: update next step message --- src/libs/NextStepUtils.ts | 12 ++++++------ tests/unit/NextStepUtilsTest.ts | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index a0e3a7ecbb59a..4b33fd42844a2 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -189,7 +189,6 @@ function buildNextStep( const approvers = getLoginsByAccountIDs([approverAccountID ?? CONST.DEFAULT_NUMBER_ID]); const reimburserAccountID = getReimburserAccountID(policy); - const hasValidAccount = !!policy?.achAccount?.accountNumber || policy.reimbursementChoice !== CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES; const type: ReportNextStep['type'] = 'neutral'; let optimisticNextStep: ReportNextStep | null; @@ -493,15 +492,16 @@ function buildNextStep( : { text: getDisplayNameForParticipant({accountID: reimburserAccountID}), type: 'strong', + clickToCopyText: reimburserAccountID === currentUserAccountID ? currentUserEmail : getPersonalDetailsForAccountID(reimburserAccountID).login, }, { text: ' to ', }, { - text: hasValidAccount ? 'pay' : 'finish setting up', + text: 'pay', }, { - text: hasValidAccount ? ' %expenses.' : ' a business bank account.', + text: ' %expenses.', }, ], }; @@ -550,7 +550,6 @@ function buildNextStepNew(params: BuildNextStepNewParams): ReportNextStep | null const approvers = getLoginsByAccountIDs([approverAccountID ?? CONST.DEFAULT_NUMBER_ID]); const reimburserAccountID = getReimburserAccountID(policy); - const hasValidAccount = !!policy?.achAccount?.accountNumber || policy?.reimbursementChoice !== CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES; const type: ReportNextStep['type'] = 'neutral'; let optimisticNextStep: ReportNextStep | null; @@ -854,15 +853,16 @@ function buildNextStepNew(params: BuildNextStepNewParams): ReportNextStep | null : { text: getDisplayNameForParticipant({accountID: reimburserAccountID}), type: 'strong', + clickToCopyText: reimburserAccountID === currentUserAccountIDParam ? currentUserEmailParam : getPersonalDetailsForAccountID(reimburserAccountID).login, }, { text: ' to ', }, { - text: hasValidAccount ? 'pay' : 'finish setting up', + text: 'pay', }, { - text: hasValidAccount ? ' %expenses.' : ' a business bank account.', + text: ' %expenses.', }, ], }; diff --git a/tests/unit/NextStepUtilsTest.ts b/tests/unit/NextStepUtilsTest.ts index c49eb2bdd6ce4..1aabd95fe1618 100644 --- a/tests/unit/NextStepUtilsTest.ts +++ b/tests/unit/NextStepUtilsTest.ts @@ -490,10 +490,10 @@ describe('libs/NextStepUtils', () => { text: ' to ', }, { - text: 'finish setting up', + text: 'pay', }, { - text: ' a business bank account.', + text: ' %expenses.', }, ]; // TODO: Replace onyx.connect with useOnyx hook (https://github.com/Expensify/App/issues/66365) @@ -744,10 +744,10 @@ describe('libs/NextStepUtils', () => { text: ' to ', }, { - text: 'finish setting up', + text: 'pay', }, { - text: ' a business bank account.', + text: ' %expenses.', }, ]; // mock the report as approved From 82d0d744decb5e95208bf35c041648dc399b1af9 Mon Sep 17 00:00:00 2001 From: Mohammad Jafarinejad <71210799+mohammadjafarinejad@users.noreply.github.com> Date: Thu, 23 Oct 2025 06:37:45 +0400 Subject: [PATCH 2/5] fix: update clickToCopyText to handle empty cases and improve test messages --- src/libs/NextStepUtils.ts | 4 ++-- tests/unit/NextStepUtilsTest.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index 4b33fd42844a2..06052a648cd28 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -492,7 +492,7 @@ function buildNextStep( : { text: getDisplayNameForParticipant({accountID: reimburserAccountID}), type: 'strong', - clickToCopyText: reimburserAccountID === currentUserAccountID ? currentUserEmail : getPersonalDetailsForAccountID(reimburserAccountID).login, + clickToCopyText: reimburserAccountID === currentUserAccountID ? currentUserEmail : '', }, { text: ' to ', @@ -853,7 +853,7 @@ function buildNextStepNew(params: BuildNextStepNewParams): ReportNextStep | null : { text: getDisplayNameForParticipant({accountID: reimburserAccountID}), type: 'strong', - clickToCopyText: reimburserAccountID === currentUserAccountIDParam ? currentUserEmailParam : getPersonalDetailsForAccountID(reimburserAccountID).login, + clickToCopyText: reimburserAccountID === currentUserAccountIDParam ? currentUserEmailParam : '', }, { text: ' to ', diff --git a/tests/unit/NextStepUtilsTest.ts b/tests/unit/NextStepUtilsTest.ts index 1aabd95fe1618..edd2df111f263 100644 --- a/tests/unit/NextStepUtilsTest.ts +++ b/tests/unit/NextStepUtilsTest.ts @@ -478,7 +478,7 @@ describe('libs/NextStepUtils', () => { test('self review', () => { optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.HOURGLASS; - // Waiting for an admin to set up a bank account + // Waiting for an admin to pay expense(s) optimisticNextStep.message = [ { text: 'Waiting for ', @@ -732,7 +732,7 @@ describe('libs/NextStepUtils', () => { test('payer', () => { optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.HOURGLASS; - // Waiting for an admin to set up a bank account + // Waiting for an admin to pay expense(s) optimisticNextStep.message = [ { text: 'Waiting for ', From c9e3152cc0fc4317a0655efcfb25c0b8c8441056 Mon Sep 17 00:00:00 2001 From: Mohammad Jafarinejad <71210799+mohammadjafarinejad@users.noreply.github.com> Date: Wed, 12 Nov 2025 12:50:04 +0400 Subject: [PATCH 3/5] Refactor buildNextStep and buildNextStepNew to use a common payerMessage logic --- src/libs/NextStepUtils.ts | 60 ++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index 60735ab9c2a08..c789e5b1db2a6 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -475,7 +475,7 @@ function buildNextStep( break; // Generates an optimistic nextStep once a report has been approved - case CONST.REPORT.STATUS_NUM.APPROVED: + case CONST.REPORT.STATUS_NUM.APPROVED: { if ( isInvoiceReport(report) || !isPayer( @@ -492,6 +492,23 @@ function buildNextStep( break; } // Self review + let payerMessage: Message; + if ( + isPayer( + { + accountID: currentUserAccountID, + email: currentUserEmail, + }, + report, + ) + ) { + payerMessage = {text: 'you', type: 'strong'}; + } else if (reimburserAccountID === -1) { + payerMessage = {text: 'an admin'}; + } else { + payerMessage = {text: getDisplayNameForParticipant({accountID: reimburserAccountID}), type: 'strong'}; + } + optimisticNextStep = { type, icon: CONST.NEXT_STEP.ICONS.HOURGLASS, @@ -499,15 +516,7 @@ function buildNextStep( { text: 'Waiting for ', }, - reimburserAccountID === -1 - ? { - text: 'an admin', - } - : { - text: getDisplayNameForParticipant({accountID: reimburserAccountID}), - type: 'strong', - clickToCopyText: reimburserAccountID === currentUserAccountID ? currentUserEmail : '', - }, + payerMessage, { text: ' to ', }, @@ -520,6 +529,7 @@ function buildNextStep( ], }; break; + } // Resets a nextStep default: @@ -836,7 +846,7 @@ function buildNextStepNew(params: BuildNextStepNewParams): ReportNextStep | null break; // Generates an optimistic nextStep once a report has been approved - case CONST.REPORT.STATUS_NUM.APPROVED: + case CONST.REPORT.STATUS_NUM.APPROVED: { if ( isInvoiceReport(report) || !isPayer( @@ -853,6 +863,23 @@ function buildNextStepNew(params: BuildNextStepNewParams): ReportNextStep | null break; } // Self review + let payerMessage: Message; + if ( + isPayer( + { + accountID: currentUserAccountIDParam, + email: currentUserEmailParam, + }, + report, + ) + ) { + payerMessage = {text: 'you', type: 'strong'}; + } else if (reimburserAccountID === -1) { + payerMessage = {text: 'an admin'}; + } else { + payerMessage = {text: getDisplayNameForParticipant({accountID: reimburserAccountID}), type: 'strong'}; + } + optimisticNextStep = { type, icon: CONST.NEXT_STEP.ICONS.HOURGLASS, @@ -860,15 +887,7 @@ function buildNextStepNew(params: BuildNextStepNewParams): ReportNextStep | null { text: 'Waiting for ', }, - reimburserAccountID === -1 - ? { - text: 'an admin', - } - : { - text: getDisplayNameForParticipant({accountID: reimburserAccountID}), - type: 'strong', - clickToCopyText: reimburserAccountID === currentUserAccountIDParam ? currentUserEmailParam : '', - }, + payerMessage, { text: ' to ', }, @@ -881,6 +900,7 @@ function buildNextStepNew(params: BuildNextStepNewParams): ReportNextStep | null ], }; break; + } // Resets a nextStep default: From eaeefcaa269e7cc989be0855d2dc338c7213fcf9 Mon Sep 17 00:00:00 2001 From: Mohammad Jafarinejad <71210799+mohammadjafarinejad@users.noreply.github.com> Date: Wed, 12 Nov 2025 15:23:30 +0400 Subject: [PATCH 4/5] Update next step messages to refer to the user as the payer --- tests/actions/IOUTest.ts | 6 +++--- tests/unit/NextStepUtilsTest.ts | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index d3684c2ac49c3..ed989709a2509 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -9892,10 +9892,10 @@ describe('actions/IOU', () => { expect(nextStep?.message).toBeDefined(); // Since the report is fully approved when admin takes control and approves, - // the next step should be about payment, which should mention the admin - // The message should equal "Waiting for Admin User to pay" + // the next step should be about payment, which should mention "you" since the admin is the payer + // The message should equal "Waiting for you to pay %expenses." const fullMessage = nextStep?.message?.map((part) => part.text).join(''); - expect(fullMessage).toBe('Waiting for an admin to pay %expenses.'); + expect(fullMessage).toBe('Waiting for you to pay %expenses.'); }); }); diff --git a/tests/unit/NextStepUtilsTest.ts b/tests/unit/NextStepUtilsTest.ts index 6fe51b80e25fe..cfdb8b0079c4b 100644 --- a/tests/unit/NextStepUtilsTest.ts +++ b/tests/unit/NextStepUtilsTest.ts @@ -478,13 +478,14 @@ describe('libs/NextStepUtils', () => { test('self review', () => { optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.HOURGLASS; - // Waiting for an admin to pay expense(s) + // Waiting for you to pay expense(s) optimisticNextStep.message = [ { text: 'Waiting for ', }, { - text: `an admin`, + text: `you`, + type: 'strong', }, { text: ' to ', @@ -506,13 +507,14 @@ describe('libs/NextStepUtils', () => { test('self review with bank account setup', () => { optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.HOURGLASS; - // Waiting for an admin to pay expense(s) + // Waiting for you to pay expense(s) optimisticNextStep.message = [ { text: 'Waiting for ', }, { - text: `an admin`, + text: `you`, + type: 'strong', }, { text: ' to ', @@ -732,13 +734,13 @@ describe('libs/NextStepUtils', () => { test('payer', () => { optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.HOURGLASS; - // Waiting for an admin to pay expense(s) + // Waiting for an admin (you) to pay expense(s) optimisticNextStep.message = [ { text: 'Waiting for ', }, { - text: 'an admin', + text: 'you', }, { text: ' to ', @@ -768,13 +770,14 @@ describe('libs/NextStepUtils', () => { test('payer with bank account setup', () => { optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.HOURGLASS; - // Waiting for an admin to pay expense(s) + // Waiting for you to pay expense(s) optimisticNextStep.message = [ { text: 'Waiting for ', }, { - text: 'an admin', + text: 'you', + type: 'strong', }, { text: ' to ', From 7a199ce604ca84a1e1767ed39974d7ee50389110 Mon Sep 17 00:00:00 2001 From: Mohammad Jafarinejad <71210799+mohammadjafarinejad@users.noreply.github.com> Date: Wed, 19 Nov 2025 06:10:54 +0400 Subject: [PATCH 5/5] Remove unused hasValidAccount variable from buildNextStep and buildNextStepNew --- src/libs/NextStepUtils.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index aae8d1ceac53a..dc686eea6e137 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -417,7 +417,6 @@ function buildNextStep( const approvers = getLoginsByAccountIDs([approverAccountID ?? CONST.DEFAULT_NUMBER_ID]); const reimburserAccountID = getReimburserAccountID(policy); - const hasValidAccount = !!policy?.achAccount?.accountNumber || policy.reimbursementChoice !== CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES; const type: ReportNextStepDeprecated['type'] = 'neutral'; let optimisticNextStep: ReportNextStepDeprecated | null; @@ -790,7 +789,6 @@ function buildNextStepNew(params: BuildNextStepNewParams): ReportNextStepDepreca const approvers = getLoginsByAccountIDs([approverAccountID ?? CONST.DEFAULT_NUMBER_ID]); const reimburserAccountID = getReimburserAccountID(policy); - const hasValidAccount = !!policy?.achAccount?.accountNumber || policy?.reimbursementChoice !== CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES; const type: ReportNextStepDeprecated['type'] = 'neutral'; let optimisticNextStep: ReportNextStepDeprecated | null;