@@ -32,7 +32,7 @@ function handleActionButtonPress(
3232 item : TransactionListItemType | TransactionReportGroupListItemType ,
3333 goToItem : ( ) => void ,
3434 isInMobileSelectionMode : boolean ,
35- snapshot : OnyxEntry < SearchResults > ,
35+ snapshotData : SearchResults [ 'data' ] | undefined ,
3636 lastPaymentMethod : OnyxEntry < LastPaymentMethod > ,
3737 currentSearchKey ?: SearchKey ,
3838) {
@@ -42,20 +42,20 @@ function handleActionButtonPress(
4242 const allReportTransactions = ( isTransactionGroupListItemType ( item ) ? item . transactions : [ item ] ) as SearchTransaction [ ] ;
4343 const hasHeldExpense = hasHeldExpenses ( '' , allReportTransactions ) ;
4444
45- if ( hasHeldExpense || isInMobileSelectionMode ) {
45+ if ( hasHeldExpense || isInMobileSelectionMode || ! snapshotData ) {
4646 goToItem ( ) ;
4747 return ;
4848 }
4949
5050 switch ( item . action ) {
5151 case CONST . SEARCH . ACTION_TYPES . PAY :
52- getPayActionCallback ( hash , item , goToItem , snapshot , lastPaymentMethod , currentSearchKey ) ;
52+ getPayActionCallback ( hash , item , goToItem , snapshotData , lastPaymentMethod , currentSearchKey ) ;
5353 return ;
5454 case CONST . SEARCH . ACTION_TYPES . APPROVE :
5555 approveMoneyRequestOnSearch ( hash , [ item . reportID ] , transactionID , currentSearchKey ) ;
5656 return ;
5757 case CONST . SEARCH . ACTION_TYPES . SUBMIT : {
58- const policy = ( snapshot ?. data ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ item . policyID } ` ] ?? { } ) as SearchPolicy ;
58+ const policy = snapshotData ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ item . policyID } ` ] ?? { } ;
5959 submitMoneyRequestOnSearch ( hash , [ item ] , [ policy ] , transactionID , currentSearchKey ) ;
6060 return ;
6161 }
@@ -64,7 +64,7 @@ function handleActionButtonPress(
6464 return ;
6565 }
6666
67- const policy = ( snapshot ?. data ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ item . policyID } ` ] ?? { } ) as Policy ;
67+ const policy = ( snapshotData ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ item . policyID } ` ] ?? { } ) as Policy ;
6868 const connectedIntegration = getValidConnectedIntegration ( policy ) ;
6969
7070 if ( ! connectedIntegration ) {
@@ -97,7 +97,7 @@ function getPayActionCallback(
9797 hash : number ,
9898 item : TransactionListItemType | TransactionReportGroupListItemType ,
9999 goToItem : ( ) => void ,
100- snapshot : OnyxEntry < SearchResults > ,
100+ snapshotData : SearchResults [ 'data' ] ,
101101 lastPaymentMethod : OnyxEntry < LastPaymentMethod > ,
102102 currentSearchKey ?: SearchKey ,
103103) {
@@ -108,7 +108,7 @@ function getPayActionCallback(
108108 return ;
109109 }
110110
111- const report = ( snapshot ?. data ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ item . reportID } ` ] ?? { } ) as SearchReport ;
111+ const report = snapshotData ?. [ `${ ONYXKEYS . COLLECTION . REPORT } ${ item . reportID } ` ] ?? { } ;
112112 const amount = Math . abs ( ( report ?. total ?? 0 ) - ( report ?. nonReimbursableTotal ?? 0 ) ) ;
113113 const transactionID = isTransactionListItemType ( item ) ? [ item . transactionID ] : undefined ;
114114
@@ -117,7 +117,7 @@ function getPayActionCallback(
117117 return ;
118118 }
119119
120- const hasVBBA = ! ! snapshot ?. data ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ item . policyID } ` ] ?. achAccount ?. bankAccountID ;
120+ const hasVBBA = ! ! snapshotData ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ item . policyID } ` ] ?. achAccount ?. bankAccountID ;
121121 if ( hasVBBA ) {
122122 payMoneyRequestOnSearch ( hash , [ { reportID : item . reportID , amount, paymentType : lastPolicyPaymentMethod } ] , transactionID , currentSearchKey ) ;
123123 return ;
0 commit comments