Skip to content

Commit

Permalink
Merge pull request #42450 from nkdengineer/fix/41336
Browse files Browse the repository at this point in the history
fix: Error message only changes after clicking Split expense button for the second time
  • Loading branch information
aldo-expensify authored Jun 4, 2024
2 parents 513c818 + 4eaa6c3 commit cb692c5
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,15 @@ function MoneyRequestConfirmationList({
const isCategoryRequired = !!policy?.requiresCategory;

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

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

Expand Down Expand Up @@ -708,21 +709,7 @@ function MoneyRequestConfirmationList({
setFormError('iou.error.invalidCategoryLength');
return;
}

if (formError) {
return;
}

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

setDidConfirm(true);

Log.info(`[IOU] Sending money via: ${paymentMethod}`);
onSendMoney?.(paymentMethod);
} else {
if (iouType !== CONST.IOU.TYPE.PAY) {
// validate the amount for distance expenses
const decimals = CurrencyUtils.getCurrencyDecimals(iouCurrencyCode);
if (isDistanceRequest && !isDistanceRequestWithPendingRoute && !MoneyRequestUtils.validateAmount(String(iouAmount), decimals)) {
Expand All @@ -739,6 +726,18 @@ 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 cb692c5

Please sign in to comment.