@@ -3,7 +3,7 @@ import isEmpty from 'lodash/isEmpty';
3
3
import React , { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
4
4
import { InteractionManager , View } from 'react-native' ;
5
5
import type { NativeScrollEvent , NativeSyntheticEvent } from 'react-native' ;
6
- import type { OnyxCollection , OnyxEntry } from 'react-native-onyx' ;
6
+ import type { OnyxEntry } from 'react-native-onyx' ;
7
7
import { useOnyx } from 'react-native-onyx' ;
8
8
import FlatList from '@components/FlatList' ;
9
9
import { AUTOSCROLL_TO_TOP_THRESHOLD } from '@components/InvertedFlatList/BaseInvertedFlatList' ;
@@ -17,7 +17,6 @@ import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
17
17
import { isActionVisibleOnMoneyRequestReport } from '@libs/MoneyRequestReportUtils' ;
18
18
import {
19
19
getFirstVisibleReportActionID ,
20
- getIOUActionForTransactionID ,
21
20
getMostRecentIOURequestActionID ,
22
21
getOneTransactionThreadReportID ,
23
22
hasNextActionMadeBySameActor ,
@@ -39,7 +38,6 @@ import CONST from '@src/CONST';
39
38
import ONYXKEYS from '@src/ONYXKEYS' ;
40
39
import ROUTES from '@src/ROUTES' ;
41
40
import type * as OnyxTypes from '@src/types/onyx' ;
42
- import type Transaction from '@src/types/onyx/Transaction' ;
43
41
import MoneyRequestReportTransactionList from './MoneyRequestReportTransactionList' ;
44
42
import SearchMoneyRequestReportEmptyState from './SearchMoneyRequestReportEmptyState' ;
45
43
@@ -57,6 +55,9 @@ type MoneyRequestReportListProps = {
57
55
/** Array of report actions for this report */
58
56
reportActions ?: OnyxTypes . ReportAction [ ] ;
59
57
58
+ /** List of transactions belonging to this report */
59
+ transactions : OnyxTypes . Transaction [ ] ;
60
+
60
61
/** If the report has newer actions to load */
61
62
hasNewerActions : boolean ;
62
63
@@ -71,21 +72,11 @@ function getParentReportAction(parentReportActions: OnyxEntry<OnyxTypes.ReportAc
71
72
return parentReportActions [ parentReportActionID ] ;
72
73
}
73
74
74
- function selectTransactionsForReportID ( transactions : OnyxCollection < OnyxTypes . Transaction > , reportID : string , reportActions : OnyxTypes . ReportAction [ ] ) {
75
- return Object . values ( transactions ?? { } ) . filter ( ( transaction ) : transaction is Transaction => {
76
- if ( ! transaction ) {
77
- return false ;
78
- }
79
- const action = getIOUActionForTransactionID ( reportActions , transaction . transactionID ) ;
80
- return transaction . reportID === reportID && ! isDeletedParentAction ( action ) ;
81
- } ) ;
82
- }
83
-
84
75
/**
85
76
* TODO make this component have the same functionalities as `ReportActionsList`
86
77
* - shouldDisplayNewMarker
87
78
*/
88
- function MoneyRequestReportActionsList ( { report, reportActions = [ ] , hasNewerActions, hasOlderActions} : MoneyRequestReportListProps ) {
79
+ function MoneyRequestReportActionsList ( { report, reportActions = [ ] , transactions = [ ] , hasNewerActions, hasOlderActions} : MoneyRequestReportListProps ) {
89
80
const styles = useThemeStyles ( ) ;
90
81
const { translate} = useLocalize ( ) ;
91
82
const { preferredLocale} = useLocalize ( ) ;
@@ -101,9 +92,6 @@ function MoneyRequestReportActionsList({report, reportActions = [], hasNewerActi
101
92
const mostRecentIOUReportActionID = useMemo ( ( ) => getMostRecentIOURequestActionID ( reportActions ) , [ reportActions ] ) ;
102
93
const transactionThreadReportID = getOneTransactionThreadReportID ( reportID , reportActions ?? [ ] , false ) ;
103
94
const firstVisibleReportActionID = useMemo ( ( ) => getFirstVisibleReportActionID ( reportActions , isOffline ) , [ reportActions , isOffline ] ) ;
104
- const [ transactions = [ ] ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION , {
105
- selector : ( allTransactions ) : OnyxTypes . Transaction [ ] => selectTransactionsForReportID ( allTransactions , reportID , reportActions ) ,
106
- } ) ;
107
95
const [ transactionThreadReport ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ transactionThreadReportID ?? CONST . DEFAULT_NUMBER_ID } ` ) ;
108
96
const [ currentUserAccountID ] = useOnyx ( ONYXKEYS . SESSION , { selector : ( session ) => session ?. accountID } ) ;
109
97
0 commit comments