diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index 86cd791f7fce..65975222718d 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -75,11 +75,29 @@ Onyx.connect({ }, }); +let didInitCurrency = false; +Onyx.connect({ + key: ONYXKEYS.IOU, + callback: (val) => { + didInitCurrency = lodashGet(val, 'didInitCurrency'); + }, +}); + +let shouldResetIOUAfterLogin = true; let currentUserPersonalDetails = {}; Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS_LIST, callback: (val) => { currentUserPersonalDetails = lodashGet(val, userAccountID, {}); + if (!val || !shouldResetIOUAfterLogin || didInitCurrency) { + return; + } + // eslint-disable-next-line no-use-before-define + resetMoneyRequestInfo(); + shouldResetIOUAfterLogin = false; + Onyx.merge(ONYXKEYS.IOU, { + didInitCurrency: true, + }); }, }); diff --git a/src/pages/iou/steps/NewRequestAmountPage.js b/src/pages/iou/steps/NewRequestAmountPage.js index c3b581cec642..488bd658cb33 100644 --- a/src/pages/iou/steps/NewRequestAmountPage.js +++ b/src/pages/iou/steps/NewRequestAmountPage.js @@ -22,6 +22,7 @@ import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; import ScreenWrapper from '../../../components/ScreenWrapper'; import {iouPropTypes, iouDefaultProps} from '../propTypes'; import CONST from '../../../CONST'; +import FullScreenLoadingIndicator from '../../../components/FullscreenLoadingIndicator'; const propTypes = { /** React Navigation route */ @@ -165,6 +166,10 @@ function NewRequestAmountPage({route, iou, report, selectedTab}) { /> ); + if (!lodashGet(iou, 'didInitCurrency', false)) { + return ; + } + // ScreenWrapper is only needed in edit mode because we have a dedicated route for the edit amount page (MoneyRequestEditAmountPage). // The rest of the cases this component is rendered through which has it's own ScreenWrapper if (!isEditing) {