Skip to content

Commit

Permalink
Merge pull request #43342 from nkdengineer/fix/recreate-41336
Browse files Browse the repository at this point in the history
fix: App allows splitting when the sum of splits is not equal to total
  • Loading branch information
mountiny authored Jun 17, 2024
2 parents c61f186 + fad7da2 commit 779d29d
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,14 @@ 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 @@ -718,20 +718,7 @@ function MoneyRequestConfirmationList({
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 @@ -745,9 +732,25 @@ function MoneyRequestConfirmationList({
return;
}

if (formError) {
return;
}

playSound(SOUNDS.DONE);
setDidConfirm(true);
onConfirm?.(selectedParticipants);
} else {
if (!paymentMethod) {
return;
}
if (formError) {
return;
}

setDidConfirm(true);

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

0 comments on commit 779d29d

Please sign in to comment.