Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/pages/iou/request/IOURequestStartPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ 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);
}, []);
Expand All @@ -88,16 +99,6 @@ 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<HTMLElement | null>(null);
const [tabBarContainerElement, setTabBarContainerElement] = useState<HTMLElement | null>(null);
const [activeTabContainerElement, setActiveTabContainerElement] = useState<HTMLElement | null>(null);
Expand Down
Loading