diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index 60af22484514..261a60d3758d 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -11,7 +11,7 @@ import type DeepValueOf from '@src/types/utils/DeepValueOf'; import {getNextApproverAccountID} from './actions/IOU'; import EmailUtils from './EmailUtils'; import {getLoginsByAccountIDs, getPersonalDetailsByIDs} from './PersonalDetailsUtils'; -import {getCorrectedAutoReportingFrequency, getReimburserAccountID} from './PolicyUtils'; +import {getApprovalWorkflow, getCorrectedAutoReportingFrequency, getReimburserAccountID} from './PolicyUtils'; import {getDisplayNameForParticipant, getPersonalDetailsForAccountID, hasViolations as hasViolationsReportUtils, isExpenseReport, isInvoiceReport, isPayer} from './ReportUtils'; let currentUserAccountID = -1; @@ -325,7 +325,8 @@ function buildNextStep(report: OnyxEntry, predictedNextStatus: ValueOf approvalMode === policyApprovalMode)) { optimisticNextStep.message = [ { text: 'Waiting for ', diff --git a/tests/unit/NextStepUtilsTest.ts b/tests/unit/NextStepUtilsTest.ts index 47db4bf51dd1..860693f377a6 100644 --- a/tests/unit/NextStepUtilsTest.ts +++ b/tests/unit/NextStepUtilsTest.ts @@ -573,6 +573,69 @@ describe('libs/NextStepUtils', () => { expect(result).toMatchObject(optimisticNextStep); }); }); + + test('approval mode enabled', () => { + report.managerID = strangeAccountID; + optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.HOURGLASS; + optimisticNextStep.message = [ + { + text: 'Waiting for ', + }, + { + text: ownerEmail, + type: 'strong', + clickToCopyText: ownerEmail, + }, + { + text: ' to ', + }, + { + text: 'approve', + }, + { + text: ' %expenses.', + }, + ]; + + return Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, { + approvalMode: CONST.POLICY.APPROVAL_MODE.BASIC, + }).then(() => { + const result = buildNextStep(report, CONST.REPORT.STATUS_NUM.SUBMITTED); + + expect(result).toMatchObject(optimisticNextStep); + }); + }); + + test('advanced approval mode enabled', () => { + report.managerID = strangeAccountID; + optimisticNextStep.icon = CONST.NEXT_STEP.ICONS.HOURGLASS; + optimisticNextStep.message = [ + { + text: 'Waiting for ', + }, + { + text: strangeEmail, + type: 'strong', + clickToCopyText: strangeEmail, + }, + { + text: ' to ', + }, + { + text: 'approve', + }, + { + text: ' %expenses.', + }, + ]; + + return Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, { + approvalMode: CONST.POLICY.APPROVAL_MODE.ADVANCED, + }).then(() => { + const result = buildNextStep(report, CONST.REPORT.STATUS_NUM.SUBMITTED); + expect(result).toMatchObject(optimisticNextStep); + }); + }); }); describe('it generates an optimistic nextStep once a report has been approved', () => {