diff --git a/src/pages/iou/request/IOURequestStartPage.tsx b/src/pages/iou/request/IOURequestStartPage.tsx index e2b267e9bd5a5..738bbbcea5b4c 100644 --- a/src/pages/iou/request/IOURequestStartPage.tsx +++ b/src/pages/iou/request/IOURequestStartPage.tsx @@ -70,17 +70,6 @@ function IOURequestStartPage({ const isFromGlobalCreate = isEmptyObject(report?.reportID); const prevTransactionReportID = usePrevious(transaction?.reportID); - // Clear out the temporary expense if the reportID in the URL has changed from the transaction's reportID. - useFocusEffect( - useCallback(() => { - // The test transaction can change the reportID of the transaction on the flow so we should prevent the reportID from being reverted again. - if (transaction?.reportID === reportID || isLoadingSelectedTab || prevTransactionReportID !== transaction?.reportID) { - return; - } - initMoneyRequest(reportID, policy, isFromGlobalCreate, transaction?.iouRequestType, transactionRequestType); - }, [transaction, policy, reportID, isFromGlobalCreate, transactionRequestType, isLoadingSelectedTab, prevTransactionReportID]), - ); - useEffect(() => { Performance.markEnd(CONST.TIMING.OPEN_CREATE_EXPENSE); }, []); @@ -99,6 +88,16 @@ function IOURequestStartPage({ [policy, reportID, isFromGlobalCreate, transaction], ); + useFocusEffect( + useCallback(() => { + // The test transaction can change the reportID of the transaction on the flow so we should prevent the reportID from being reverted again. + if (isLoadingSelectedTab || prevTransactionReportID !== transaction?.reportID) { + return; + } + resetIOUTypeIfChanged(transactionRequestType); + }, [transaction?.reportID, resetIOUTypeIfChanged, transactionRequestType, isLoadingSelectedTab, prevTransactionReportID]), + ); + const [headerWithBackBtnContainerElement, setHeaderWithBackButtonContainerElement] = useState(null); const [tabBarContainerElement, setTabBarContainerElement] = useState(null); const [activeTabContainerElement, setActiveTabContainerElement] = useState(null);