Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change message when reimbursementChoice is reimburseNo #49837

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
54 changes: 21 additions & 33 deletions src/libs/NextStepUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
const type: ReportNextStep['type'] = 'neutral';
let optimisticNextStep: ReportNextStep | null;

const noActionRequired = {
icon: CONST.NEXT_STEP.ICONS.CHECKMARK,
type,
message: [
{
text: 'No further action required!',
},
],
};

switch (predictedNextStatus) {
// Generates an optimistic nextStep once a report has been opened
case CONST.REPORT.STATUS_NUM.OPEN:
Expand Down Expand Up @@ -126,6 +136,12 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
],
};

if (policy.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_NO) {
optimisticNextStep = noActionRequired;

break;
}

// Scheduled submit enabled
if (harvesting?.enabled && autoReportingFrequency !== CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL) {
optimisticNextStep.message = [
Expand Down Expand Up @@ -217,16 +233,10 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
}

// Generates an optimistic nextStep once a report has been closed for example in the case of Submit and Close approval flow
// or when a report has been paid
case CONST.REPORT.STATUS_NUM.CLOSED:
optimisticNextStep = {
icon: CONST.NEXT_STEP.ICONS.CHECKMARK,
type,
message: [
{
text: 'No further action required!',
},
],
};
case CONST.REPORT.STATUS_NUM.REIMBURSED:
optimisticNextStep = noActionRequired;

break;

Expand All @@ -242,15 +252,8 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
report,
)
) {
optimisticNextStep = {
type,
icon: CONST.NEXT_STEP.ICONS.CHECKMARK,
message: [
{
text: 'No further action required!',
},
],
};
optimisticNextStep = noActionRequired;

break;
}
// Self review
Expand Down Expand Up @@ -278,21 +281,6 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
};
break;

// Generates an optimistic nextStep once a report has been paid
case CONST.REPORT.STATUS_NUM.REIMBURSED:
// Paid with wallet
optimisticNextStep = {
type,
icon: CONST.NEXT_STEP.ICONS.CHECKMARK,
message: [
{
text: 'No further action required!',
},
],
};

break;

// Resets a nextStep
default:
optimisticNextStep = null;
Expand Down
Loading