Skip to content

Commit 22e67db

Browse files
authored
Merge pull request #62426 from FitseTLT/fix-next-step-update-bug
fix - Chat- Next step changes when changing category
2 parents 6cef078 + b98c928 commit 22e67db

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/libs/NextStepUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function buildNextStep(report: OnyxEntry<Report>, predictedNextStatus: ValueOf<t
147147
const approvers = getLoginsByAccountIDs([approverAccountID ?? CONST.DEFAULT_NUMBER_ID]);
148148

149149
const reimburserAccountID = getReimburserAccountID(policy);
150-
const hasValidAccount = !!policy?.achAccount?.accountNumber;
150+
const hasValidAccount = !!policy?.achAccount?.accountNumber || policy.reimbursementChoice !== CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES;
151151
const type: ReportNextStep['type'] = 'neutral';
152152
let optimisticNextStep: ReportNextStep | null;
153153

src/libs/actions/IOU.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4151,7 +4151,7 @@ function getUpdateMoneyRequestParams(
41514151
},
41524152
});
41534153
}
4154-
if (violationsOnyxData) {
4154+
if (violationsOnyxData && (iouReport?.statusNum ?? CONST.REPORT.STATUS_NUM.OPEN) === CONST.REPORT.STATUS_NUM.OPEN) {
41554155
const currentNextStep = allNextSteps[`${ONYXKEYS.COLLECTION.NEXT_STEP}${iouReport?.reportID}`] ?? {};
41564156
const shouldFixViolations = Array.isArray(violationsOnyxData.value) && violationsOnyxData.value.length > 0;
41574157
optimisticData.push({

tests/unit/NextStepUtilsTest.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('libs/NextStepUtils', () => {
3131
type: 'team',
3232
outputCurrency: CONST.CURRENCY.USD,
3333
isPolicyExpenseChatEnabled: true,
34-
reimbursementChoice: CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL,
34+
reimbursementChoice: CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES,
3535
};
3636
const optimisticNextStep: ReportNextStep = {
3737
type: 'neutral',
@@ -684,9 +684,13 @@ describe('libs/NextStepUtils', () => {
684684
},
685685
];
686686

687-
const result = buildNextStep(report, CONST.REPORT.STATUS_NUM.APPROVED);
687+
return Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {
688+
reimbursementChoice: CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL,
689+
}).then(() => {
690+
const result = buildNextStep(report, CONST.REPORT.STATUS_NUM.APPROVED);
688691

689-
expect(result).toMatchObject(optimisticNextStep);
692+
expect(result).toMatchObject(optimisticNextStep);
693+
});
690694
});
691695

692696
test('payer', () => {

0 commit comments

Comments
 (0)