@@ -70,6 +70,17 @@ function IOURequestStartPage({
70
70
const isFromGlobalCreate = isEmptyObject ( report ?. reportID ) ;
71
71
const prevTransactionReportID = usePrevious ( transaction ?. reportID ) ;
72
72
73
+ // Clear out the temporary expense if the reportID in the URL has changed from the transaction's reportID.
74
+ useFocusEffect (
75
+ useCallback ( ( ) => {
76
+ // The test transaction can change the reportID of the transaction on the flow so we should prevent the reportID from being reverted again.
77
+ if ( transaction ?. reportID === reportID || isLoadingSelectedTab || prevTransactionReportID !== transaction ?. reportID ) {
78
+ return ;
79
+ }
80
+ initMoneyRequest ( reportID , policy , isFromGlobalCreate , transaction ?. iouRequestType , transactionRequestType ) ;
81
+ } , [ transaction , policy , reportID , isFromGlobalCreate , transactionRequestType , isLoadingSelectedTab , prevTransactionReportID ] ) ,
82
+ ) ;
83
+
73
84
useEffect ( ( ) => {
74
85
Performance . markEnd ( CONST . TIMING . OPEN_CREATE_EXPENSE ) ;
75
86
} , [ ] ) ;
@@ -88,16 +99,6 @@ function IOURequestStartPage({
88
99
[ policy , reportID , isFromGlobalCreate , transaction ] ,
89
100
) ;
90
101
91
- useFocusEffect (
92
- useCallback ( ( ) => {
93
- // The test transaction can change the reportID of the transaction on the flow so we should prevent the reportID from being reverted again.
94
- if ( isLoadingSelectedTab || prevTransactionReportID !== transaction ?. reportID ) {
95
- return ;
96
- }
97
- resetIOUTypeIfChanged ( transactionRequestType ) ;
98
- } , [ transaction ?. reportID , resetIOUTypeIfChanged , transactionRequestType , isLoadingSelectedTab , prevTransactionReportID ] ) ,
99
- ) ;
100
-
101
102
const [ headerWithBackBtnContainerElement , setHeaderWithBackButtonContainerElement ] = useState < HTMLElement | null > ( null ) ;
102
103
const [ tabBarContainerElement , setTabBarContainerElement ] = useState < HTMLElement | null > ( null ) ;
103
104
const [ activeTabContainerElement , setActiveTabContainerElement ] = useState < HTMLElement | null > ( null ) ;
0 commit comments