11import { useFocusEffect } from '@react-navigation/native' ;
22import { iouRequestPolicyCollectionSelector } from '@selectors/Policy' ;
3+ import { validTransactionDraftIDsSelector } from '@selectors/TransactionDraft' ;
34import React , { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
45import { Keyboard , View } from 'react-native' ;
56import type { OnyxEntry } from 'react-native-onyx' ;
@@ -47,7 +48,7 @@ import type SCREENS from '@src/SCREENS';
4748import type { DismissedProductTraining , SelectedTabRequest } from '@src/types/onyx' ;
4849import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
4950import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue' ;
50- import IOURequestStepAmount from './step/IOURequestStepAmount' ;
51+ import { IOURequestStepAmountWithTransactionOnly } from './step/IOURequestStepAmount' ;
5152import IOURequestStepDestination from './step/IOURequestStepDestination' ;
5253import IOURequestStepDistance from './step/IOURequestStepDistance' ;
5354import IOURequestStepHours from './step/IOURequestStepHours' ;
@@ -83,6 +84,7 @@ function IOURequestStartPage({
8384 const shouldUseTab = iouType !== CONST . IOU . TYPE . SEND && iouType !== CONST . IOU . TYPE . PAY && iouType !== CONST . IOU . TYPE . INVOICE ;
8485 const personalPolicy = usePersonalPolicy ( ) ;
8586 const [ report ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ reportID } ` ) ;
87+ const [ reportDraft ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT_DRAFT } ${ reportID } ` ) ;
8688 const [ parentReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ report ?. parentReportID } ` ) ;
8789 const policy = usePolicy ( report ?. policyID ) ;
8890 const [ lastSelectedTab , selectedTabResult ] = useOnyx ( `${ ONYXKEYS . COLLECTION . SELECTED_TAB } ${ CONST . TAB . IOU_REQUEST_TYPE } ` ) ;
@@ -97,11 +99,11 @@ function IOURequestStartPage({
9799 } ) ;
98100
99101 const [ lastSelectedDistanceRates ] = useOnyx ( ONYXKEYS . NVP_LAST_SELECTED_DISTANCE_RATES ) ;
100- const [ draftTransactions ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION_DRAFT ) ;
101102 const [ isMultiScanEnabled , setIsMultiScanEnabled ] = useState ( false ) ;
102103 const [ currentDate ] = useOnyx ( ONYXKEYS . CURRENT_DATE ) ;
103104 const { isOffline} = useNetwork ( ) ;
104105 const [ hasUserSubmittedExpenseOrScannedReceipt ] = useOnyx ( ONYXKEYS . NVP_DISMISSED_PRODUCT_TRAINING , { selector : isTestReceiptTooltipDismissedSelector } ) ;
106+ const [ draftTransactionIDs ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION_DRAFT , { selector : validTransactionDraftIDsSelector } ) ;
105107 const hasOnlyPersonalPolicies = useMemo ( ( ) => hasOnlyPersonalPoliciesUtil ( allPolicies ) , [ allPolicies ] ) ;
106108
107109 const perDiemInputRef = useRef < AnimatedTextInputRef | null > ( null ) ;
@@ -201,7 +203,7 @@ function IOURequestStartPage({
201203 lastSelectedDistanceRates,
202204 currentUserPersonalDetails,
203205 hasOnlyPersonalPolicies,
204- draftTransactions ,
206+ draftTransactionIDs ,
205207 } ) ;
206208 } ,
207209 [
@@ -218,7 +220,7 @@ function IOURequestStartPage({
218220 lastSelectedDistanceRates ,
219221 currentUserPersonalDetails ,
220222 hasOnlyPersonalPolicies ,
221- draftTransactions ,
223+ draftTransactionIDs ,
222224 ] ,
223225 ) ;
224226
@@ -331,10 +333,12 @@ function IOURequestStartPage({
331333 < TopTab . Screen name = { CONST . TAB_REQUEST . MANUAL } >
332334 { ( ) => (
333335 < TabScreenWithFocusTrapWrapper >
334- < IOURequestStepAmount
336+ < IOURequestStepAmountWithTransactionOnly
335337 shouldKeepUserInput
336338 route = { route }
337339 navigation = { navigation }
340+ report = { report }
341+ reportDraft = { reportDraft }
338342 />
339343 </ TabScreenWithFocusTrapWrapper >
340344 ) }
@@ -415,10 +419,12 @@ function IOURequestStartPage({
415419 onContainerElementChanged = { setActiveTabContainerElement }
416420 style = { [ styles . flexColumn , styles . flex1 ] }
417421 >
418- < IOURequestStepAmount
422+ < IOURequestStepAmountWithTransactionOnly
419423 route = { route }
420424 navigation = { navigation }
421425 shouldKeepUserInput
426+ report = { report }
427+ reportDraft = { reportDraft }
422428 />
423429 </ FocusTrapContainerElement >
424430 ) }
0 commit comments