diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index 3b42382b10f9..db31ab02a3e5 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -254,14 +254,14 @@ function buildNextStep(report: Report | EmptyObject, predictedNextStatus: ValueO text: 'Waiting for ', }, { - text: 'you', + text: managerDisplayName, type: 'strong', }, { text: ' to ', }, { - text: 'review', + text: 'pay', type: 'strong', }, { @@ -272,10 +272,23 @@ function buildNextStep(report: Report | EmptyObject, predictedNextStatus: ValueO // Another owner if (!isOwner) { - optimisticNextStep.title = 'Finished!'; optimisticNextStep.message = [ { - text: 'No further action required!', + text: 'Waiting for ', + }, + { + text: 'you', + type: 'strong', + }, + { + text: ' to ', + }, + { + text: 'pay', + type: 'strong', + }, + { + text: ' %expenses.', }, ]; } diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 6dab37b98ee3..627c50065398 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -3631,6 +3631,7 @@ function cancelPayment(expenseReport: OnyxTypes.Report, chatReport: OnyxTypes.Re stateNum = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATE_NUM.SUBMITTED : CONST.REPORT.STATE_NUM.APPROVED; statusNum = approvalMode === CONST.POLICY.APPROVAL_MODE.OPTIONAL ? CONST.REPORT.STATUS_NUM.CLOSED : CONST.REPORT.STATUS_NUM.APPROVED; } + const optimisticNextStep = NextStepUtils.buildNextStep(expenseReport, statusNum); const optimisticData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, @@ -3655,6 +3656,14 @@ function cancelPayment(expenseReport: OnyxTypes.Report, chatReport: OnyxTypes.Re }, ]; + if (!isFree) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${expenseReport.reportID}`, + value: optimisticNextStep, + }); + } + const successData: OnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, @@ -3696,6 +3705,13 @@ function cancelPayment(expenseReport: OnyxTypes.Report, chatReport: OnyxTypes.Re }, }); } + if (!isFree) { + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${expenseReport.reportID}`, + value: NextStepUtils.buildNextStep(expenseReport, CONST.REPORT.STATUS_NUM.REIMBURSED), + }); + } API.write( WRITE_COMMANDS.CANCEL_PAYMENT, diff --git a/tests/unit/NextStepUtilsTest.ts b/tests/unit/NextStepUtilsTest.ts index 568c641d2ac5..5f4b1a6ed96b 100644 --- a/tests/unit/NextStepUtilsTest.ts +++ b/tests/unit/NextStepUtilsTest.ts @@ -364,7 +364,7 @@ describe('libs/NextStepUtils', () => { text: ' to ', }, { - text: 'review', + text: 'pay', type: 'strong', }, { @@ -457,7 +457,7 @@ describe('libs/NextStepUtils', () => { text: ' to ', }, { - text: 'review', + text: 'pay', type: 'strong', }, { @@ -472,10 +472,24 @@ describe('libs/NextStepUtils', () => { test('another owner', () => { report.ownerAccountID = strangeAccountID; - optimisticNextStep.title = 'Finished!'; + optimisticNextStep.title = 'Next Steps:'; optimisticNextStep.message = [ { - text: 'No further action required!', + text: 'Waiting for ', + }, + { + text: 'you', + type: 'strong', + }, + { + text: ' to ', + }, + { + text: 'pay', + type: 'strong', + }, + { + text: ' %expenses.', }, ];