11import { shouldFailAllRequestsSelector } from '@selectors/Network' ;
2+ import type { OnyxEntry } from 'react-native-onyx' ;
23import type { ValueOf } from 'type-fest' ;
34import useNetwork from '@hooks/useNetwork' ;
45import useOnyx from '@hooks/useOnyx' ;
5- import usePaginatedReportActions from '@hooks/usePaginatedReportActions' ;
66import { setNameValuePair } from '@libs/actions/User' ;
7- import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID' ;
87import Navigation from '@libs/Navigation/Navigation' ;
9- import { getFilteredReportActionsForReportView , getOriginalMessage , isMoneyRequestAction } from '@libs/ReportActionsUtils' ;
108import { changeMoneyRequestHoldStatus , rejectMoneyRequestReason } from '@libs/ReportUtils' ;
119import { dismissRejectUseExplanation } from '@userActions/IOU' ;
1210import CONST from '@src/CONST' ;
@@ -21,17 +19,19 @@ type RejectModalAction = ValueOf<
2119> ;
2220
2321type MoneyReportHeaderEducationalModalsProps = {
22+ requestParentReportAction : OnyxTypes . ReportAction | null | undefined ;
23+ transaction : OnyxEntry < OnyxTypes . Transaction > ;
2424 reportID : string | undefined ;
25- transactionThreadReportID : string | undefined ;
2625 isHoldEducationalVisible : boolean ;
2726 rejectModalAction : RejectModalAction | null ;
2827 onHoldEducationalDismissed : ( ) => void ;
2928 onRejectModalDismissed : ( ) => void ;
3029} ;
3130
3231function MoneyReportHeaderEducationalModals ( {
32+ requestParentReportAction,
33+ transaction,
3334 reportID,
34- transactionThreadReportID,
3535 isHoldEducationalVisible,
3636 rejectModalAction,
3737 onHoldEducationalDismissed,
@@ -40,18 +40,6 @@ function MoneyReportHeaderEducationalModals({
4040 const { isOffline} = useNetwork ( ) ;
4141 const [ shouldFailAllRequests ] = useOnyx ( ONYXKEYS . NETWORK , { selector : shouldFailAllRequestsSelector } ) ;
4242
43- const [ transactionThreadReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ transactionThreadReportID } ` ) ;
44- const { reportActions : unfilteredReportActions } = usePaginatedReportActions ( reportID ) ;
45- const reportActions = getFilteredReportActionsForReportView ( unfilteredReportActions ) ;
46-
47- const requestParentReportAction =
48- reportActions && transactionThreadReport ?. parentReportActionID
49- ? reportActions . find ( ( action ) : action is OnyxTypes . ReportAction < typeof CONST . REPORT . ACTIONS . TYPE . IOU > => action . reportActionID === transactionThreadReport . parentReportActionID )
50- : null ;
51-
52- const iouTransactionID = isMoneyRequestAction ( requestParentReportAction ) ? getOriginalMessage ( requestParentReportAction ) ?. IOUTransactionID : undefined ;
53- const [ transaction ] = useOnyx ( `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ getNonEmptyStringOnyxID ( iouTransactionID ) } ` ) ;
54-
5543 const dismissModalAndUpdateUseHold = ( ) => {
5644 onHoldEducationalDismissed ( ) ;
5745 setNameValuePair ( ONYXKEYS . NVP_DISMISSED_HOLD_USE_EXPLANATION , true , false , ! shouldFailAllRequests ) ;
0 commit comments