Skip to content

Commit

Permalink
Merge pull request #43223 from ishpaul777/revert-42450-fix/41336
Browse files Browse the repository at this point in the history
[CP Staging] Revert "fix: Error message only changes after clicking Split expense button for the second time"

(cherry picked from commit c03bdc6)
  • Loading branch information
mountiny authored and OSBotify committed Jun 6, 2024
1 parent 746a268 commit fe3483b
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,14 @@ function MoneyRequestConfirmationList({
const isCategoryRequired = !!policy?.requiresCategory;

useEffect(() => {
if (shouldDisplayFieldError && didConfirmSplit) {
setFormError('iou.error.genericSmartscanFailureMessage');
return;
}

if (shouldDisplayFieldError && hasSmartScanFailed) {
setFormError('iou.receiptScanningFailed');
return;
}
if (shouldDisplayFieldError && didConfirmSplit) {
setFormError('iou.error.genericSmartscanFailureMessage');
return;
}
// reset the form error whenever the screen gains or loses focus
setFormError('');

Expand Down Expand Up @@ -709,7 +708,21 @@ function MoneyRequestConfirmationList({
setFormError('iou.error.invalidCategoryLength');
return;
}
if (iouType !== CONST.IOU.TYPE.PAY) {

if (formError) {
return;
}

if (iouType === CONST.IOU.TYPE.PAY) {
if (!paymentMethod) {
return;
}

setDidConfirm(true);

Log.info(`[IOU] Sending money via: ${paymentMethod}`);
onSendMoney?.(paymentMethod);
} else {
// validate the amount for distance expenses
const decimals = CurrencyUtils.getCurrencyDecimals(iouCurrencyCode);
if (isDistanceRequest && !isDistanceRequestWithPendingRoute && !MoneyRequestUtils.validateAmount(String(iouAmount), decimals)) {
Expand All @@ -726,18 +739,6 @@ function MoneyRequestConfirmationList({
playSound(SOUNDS.DONE);
setDidConfirm(true);
onConfirm?.(selectedParticipants);
} else {
if (formError) {
return;
}
if (!paymentMethod) {
return;
}

setDidConfirm(true);

Log.info(`[IOU] Sending money via: ${paymentMethod}`);
onSendMoney?.(paymentMethod);
}
},
[
Expand Down

0 comments on commit fe3483b

Please sign in to comment.