From 33521cbc88cd4baa18989d1e3386d3b66fd6f08e Mon Sep 17 00:00:00 2001 From: Ishpaul Singh <104348397+ishpaul777@users.noreply.github.com> Date: Fri, 7 Jun 2024 02:11:12 +0530 Subject: [PATCH] Revert "fix: Error message only changes after clicking Split expense button for the second time" --- .../MoneyRequestConfirmationList.tsx | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index b7cc0741a152..b63fa7157c63 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -344,15 +344,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(''); @@ -714,7 +713,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)) { @@ -731,18 +744,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); } }, [