diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index 48181db8b168..64db07491100 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -97,6 +97,16 @@ function buildNextStep(report: OnyxEntry, predictedNextStatus: ValueOf, predictedNextStatus: ValueOf, predictedNextStatus: ValueOf, predictedNextStatus: ValueOf) { + const isInstantSubmitEnabled = PolicyUtils.isInstantSubmitEnabled(policy); + const isSubmitAndClose = PolicyUtils.isSubmitAndClose(policy); + const arePaymentsDisabled = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO; + + if (isInstantSubmitEnabled && arePaymentsDisabled && isSubmitAndClose) { + return { + stateNum: CONST.REPORT.STATE_NUM.APPROVED, + statusNum: CONST.REPORT.STATUS_NUM.CLOSED, + }; + } + + if (isInstantSubmitEnabled) { + return { + stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, + statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, + }; + } + + return { + stateNum: CONST.REPORT.STATE_NUM.OPEN, + statusNum: CONST.REPORT.STATUS_NUM.OPEN, + }; +} + /** * Builds an optimistic Expense report with a randomly generated reportID * @@ -4510,10 +4539,7 @@ function buildOptimisticExpenseReport( const formattedTotal = CurrencyUtils.convertToDisplayString(storedTotal, currency); const policy = getPolicy(policyID); - const isInstantSubmitEnabled = PolicyUtils.isInstantSubmitEnabled(policy); - - const stateNum = isInstantSubmitEnabled ? CONST.REPORT.STATE_NUM.SUBMITTED : CONST.REPORT.STATE_NUM.OPEN; - const statusNum = isInstantSubmitEnabled ? CONST.REPORT.STATUS_NUM.SUBMITTED : CONST.REPORT.STATUS_NUM.OPEN; + const {stateNum, statusNum} = getExpenseReportStateAndStatus(policy); const expenseReport: OptimisticExpenseReport = { reportID: generateReportID(),