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 a next step when reimbursing #36880

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/libs/NextStepUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,22 @@ function parseMessage(messages: Message[] | undefined) {
}

type BuildNextStepParameters = {
isPaidWithWallet?: boolean;
isPaidWithExpensify?: boolean;
};

/**
* Generates an optimistic nextStep based on a current report status and other properties.
*
* @param report
* @param predictedNextStatus - a next expected status of the report
* @param parameters.isPaidWithWallet - Whether a report has been paid with the wallet or outside of Expensify
* @param parameters.isPaidWithExpensify - Whether a report has been paid with Expensify or outside
* @returns nextStep
*/
function buildNextStep(report: Report | EmptyObject, predictedNextStatus: ValueOf<typeof CONST.REPORT.STATUS_NUM>, {isPaidWithWallet}: BuildNextStepParameters = {}): ReportNextStep | null {
function buildNextStep(
report: Report | EmptyObject,
predictedNextStatus: ValueOf<typeof CONST.REPORT.STATUS_NUM>,
{isPaidWithExpensify}: BuildNextStepParameters = {},
): ReportNextStep | null {
if (!ReportUtils.isExpenseReport(report)) {
return null;
}
Expand Down Expand Up @@ -317,7 +321,7 @@ function buildNextStep(report: Report | EmptyObject, predictedNextStatus: ValueO
};

// Paid outside of Expensify
if (isPaidWithWallet === false) {
if (isPaidWithExpensify === false) {
optimisticNextStep.message?.push({text: ' outside of Expensify'});
}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3314,7 +3314,7 @@ function getPayMoneyRequestParams(chatReport: OnyxTypes.Report, iouReport: OnyxT
}

const currentNextStep = allNextSteps[`${ONYXKEYS.COLLECTION.NEXT_STEP}${iouReport.reportID}`] ?? null;
const optimisticNextStep = NextStepUtils.buildNextStep(iouReport, CONST.REPORT.STATUS_NUM.REIMBURSED, {isPaidWithWallet: paymentMethodType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY});
const optimisticNextStep = NextStepUtils.buildNextStep(iouReport, CONST.REPORT.STATUS_NUM.REIMBURSED, {isPaidWithExpensify: paymentMethodType === CONST.IOU.PAYMENT_TYPE.VBBA});

const optimisticData: OnyxUpdate[] = [
{
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/NextStepUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ describe('libs/NextStepUtils', () => {
},
];

const result = NextStepUtils.buildNextStep(report, CONST.REPORT.STATUS_NUM.REIMBURSED, {isPaidWithWallet: true});
const result = NextStepUtils.buildNextStep(report, CONST.REPORT.STATUS_NUM.REIMBURSED, {isPaidWithExpensify: true});

expect(result).toMatchObject(optimisticNextStep);
});
Expand All @@ -546,7 +546,7 @@ describe('libs/NextStepUtils', () => {
},
];

const result = NextStepUtils.buildNextStep(report, CONST.REPORT.STATUS_NUM.REIMBURSED, {isPaidWithWallet: false});
const result = NextStepUtils.buildNextStep(report, CONST.REPORT.STATUS_NUM.REIMBURSED, {isPaidWithExpensify: false});

expect(result).toMatchObject(optimisticNextStep);
});
Expand Down
Loading