Skip to content

Commit c03bdc6

Browse files
authored
Merge pull request #43223 from ishpaul777/revert-42450-fix/41336
[CP Staging] Revert "fix: Error message only changes after clicking Split expense button for the second time"
2 parents 60ca2ff + 33521cb commit c03bdc6

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/components/MoneyRequestConfirmationList.tsx

+19-18
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,14 @@ function MoneyRequestConfirmationList({
344344
const isCategoryRequired = !!policy?.requiresCategory;
345345

346346
useEffect(() => {
347-
if (shouldDisplayFieldError && didConfirmSplit) {
348-
setFormError('iou.error.genericSmartscanFailureMessage');
349-
return;
350-
}
351-
352347
if (shouldDisplayFieldError && hasSmartScanFailed) {
353348
setFormError('iou.receiptScanningFailed');
354349
return;
355350
}
351+
if (shouldDisplayFieldError && didConfirmSplit) {
352+
setFormError('iou.error.genericSmartscanFailureMessage');
353+
return;
354+
}
356355
// reset the form error whenever the screen gains or loses focus
357356
setFormError('');
358357

@@ -714,7 +713,21 @@ function MoneyRequestConfirmationList({
714713
setFormError('iou.error.invalidCategoryLength');
715714
return;
716715
}
717-
if (iouType !== CONST.IOU.TYPE.PAY) {
716+
717+
if (formError) {
718+
return;
719+
}
720+
721+
if (iouType === CONST.IOU.TYPE.PAY) {
722+
if (!paymentMethod) {
723+
return;
724+
}
725+
726+
setDidConfirm(true);
727+
728+
Log.info(`[IOU] Sending money via: ${paymentMethod}`);
729+
onSendMoney?.(paymentMethod);
730+
} else {
718731
// validate the amount for distance expenses
719732
const decimals = CurrencyUtils.getCurrencyDecimals(iouCurrencyCode);
720733
if (isDistanceRequest && !isDistanceRequestWithPendingRoute && !MoneyRequestUtils.validateAmount(String(iouAmount), decimals)) {
@@ -731,18 +744,6 @@ function MoneyRequestConfirmationList({
731744
playSound(SOUNDS.DONE);
732745
setDidConfirm(true);
733746
onConfirm?.(selectedParticipants);
734-
} else {
735-
if (formError) {
736-
return;
737-
}
738-
if (!paymentMethod) {
739-
return;
740-
}
741-
742-
setDidConfirm(true);
743-
744-
Log.info(`[IOU] Sending money via: ${paymentMethod}`);
745-
onSendMoney?.(paymentMethod);
746747
}
747748
},
748749
[

0 commit comments

Comments
 (0)