From f2da0c74ca47d0fed0c623f20413e58516b8d2a1 Mon Sep 17 00:00:00 2001 From: akamefi202 Date: Tue, 5 Sep 2023 14:33:54 -0400 Subject: [PATCH] reset money request info --- src/pages/iou/steps/NewRequestAmountPage.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index 32a9134cb101..e23efd5f7d12 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -99,6 +99,12 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { // Because we use Onyx to store IOU info, when we try to make two different money requests from different tabs, // it can result in an IOU sent with improper values. In such cases we want to reset the flow and redirect the user to the first step of the IOU. useEffect(() => { + const moneyRequestID = `${iouType}${reportID}`; + const shouldReset = iou.id !== moneyRequestID; + if (shouldReset) { + IOU.resetMoneyRequestInfo(moneyRequestID); + } + if (isEditing) { // ID in Onyx could change by initiating a new request in a separate browser tab or completing a request if (prevMoneyRequestID.current !== iou.id) { @@ -109,11 +115,6 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType, reportID), true); return; } - const moneyRequestID = `${iouType}${reportID}`; - const shouldReset = iou.id !== moneyRequestID; - if (shouldReset) { - IOU.resetMoneyRequestInfo(moneyRequestID); - } if (!isDistanceRequestTab && (_.isEmpty(iou.participants) || iou.amount === 0 || shouldReset)) { Navigation.goBack(ROUTES.getMoneyRequestRoute(iouType, reportID), true);