@@ -22,7 +22,8 @@ import * as DeviceCapabilities from '@libs/DeviceCapabilities';
22
22
import Log from '@libs/Log' ;
23
23
import memoize from '@libs/memoize' ;
24
24
import * as ReportUtils from '@libs/ReportUtils' ;
25
- import * as SearchUtils from '@libs/SearchUtils' ;
25
+ import * as SearchQueryUtils from '@libs/SearchQueryUtils' ;
26
+ import * as SearchUIUtils from '@libs/SearchUIUtils' ;
26
27
import Navigation from '@navigation/Navigation' ;
27
28
import type { AuthScreensParamList } from '@navigation/types' ;
28
29
import EmptySearchView from '@pages/Search/EmptySearchView' ;
@@ -60,11 +61,11 @@ function mapToItemWithSelectionInfo(
60
61
canSelectMultiple : boolean ,
61
62
shouldAnimateInHighlight : boolean ,
62
63
) {
63
- if ( SearchUtils . isReportActionListItemType ( item ) ) {
64
+ if ( SearchUIUtils . isReportActionListItemType ( item ) ) {
64
65
return item ;
65
66
}
66
67
67
- return SearchUtils . isTransactionListItemType ( item )
68
+ return SearchUIUtils . isTransactionListItemType ( item )
68
69
? mapToTransactionItemWithSelectionInfo ( item , selectedTransactions , canSelectMultiple , shouldAnimateInHighlight )
69
70
: {
70
71
...item ,
@@ -139,7 +140,7 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
139
140
140
141
const getItemHeight = useCallback (
141
142
( item : TransactionListItemType | ReportListItemType | ReportActionListItemType ) => {
142
- if ( SearchUtils . isTransactionListItemType ( item ) || SearchUtils . isReportActionListItemType ( item ) ) {
143
+ if ( SearchUIUtils . isTransactionListItemType ( item ) || SearchUIUtils . isReportActionListItemType ( item ) ) {
143
144
return isLargeScreenWidth ? variables . optionRowHeight + listItemPadding : transactionItemMobileHeight + listItemPadding ;
144
145
}
145
146
@@ -186,9 +187,9 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
186
187
const isDataLoaded = searchResults ?. data !== undefined && searchResults ?. search ?. type === type && searchResults ?. search ?. status === status ;
187
188
const shouldShowLoadingState = ! isOffline && ! isDataLoaded ;
188
189
const shouldShowLoadingMoreItems = ! shouldShowLoadingState && searchResults ?. search ?. isLoading && searchResults ?. search ?. offset > 0 ;
189
- const isSearchResultsEmpty = ! searchResults ?. data || SearchUtils . isSearchResultsEmpty ( searchResults ) ;
190
+ const isSearchResultsEmpty = ! searchResults ?. data || SearchUIUtils . isSearchResultsEmpty ( searchResults ) ;
190
191
const prevIsSearchResultEmpty = usePrevious ( isSearchResultsEmpty ) ;
191
- const data = searchResults === undefined ? [ ] : SearchUtils . getSections ( type , status , searchResults . data , searchResults . search ) ;
192
+ const data = searchResults === undefined ? [ ] : SearchUIUtils . getSections ( type , status , searchResults . data , searchResults . search ) ;
192
193
193
194
useEffect ( ( ) => {
194
195
/** We only want to display the skeleton for the status filters the first time we load them for a specific data type */
@@ -260,8 +261,8 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
260
261
return < FullPageOfflineBlockingView > { null } </ FullPageOfflineBlockingView > ;
261
262
}
262
263
263
- const ListItem = SearchUtils . getListItem ( type , status ) ;
264
- const sortedData = SearchUtils . getSortedSections ( type , status , data , sortBy , sortOrder ) ;
264
+ const ListItem = SearchUIUtils . getListItem ( type , status ) ;
265
+ const sortedData = SearchUIUtils . getSortedSections ( type , status , data , sortBy , sortOrder ) ;
265
266
const sortedSelectedData = sortedData . map ( ( item ) => {
266
267
const baseKey = `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ ( item as TransactionListItemType ) . transactionID } ` ;
267
268
// Check if the base key matches the newSearchResultKey (TransactionListItemType)
@@ -288,10 +289,10 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
288
289
}
289
290
290
291
const toggleTransaction = ( item : TransactionListItemType | ReportListItemType | ReportActionListItemType ) => {
291
- if ( SearchUtils . isReportActionListItemType ( item ) ) {
292
+ if ( SearchUIUtils . isReportActionListItemType ( item ) ) {
292
293
return ;
293
294
}
294
- if ( SearchUtils . isTransactionListItemType ( item ) ) {
295
+ if ( SearchUIUtils . isTransactionListItemType ( item ) ) {
295
296
if ( ! item . keyForList ) {
296
297
return ;
297
298
}
@@ -322,21 +323,21 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
322
323
323
324
const openReport = ( item : TransactionListItemType | ReportListItemType | ReportActionListItemType ) => {
324
325
const isFromSelfDM = item . reportID === CONST . REPORT . UNREPORTED_REPORTID ;
325
- let reportID = SearchUtils . isTransactionListItemType ( item ) && ( ! item . isFromOneTransactionReport || isFromSelfDM ) ? item . transactionThreadReportID : item . reportID ;
326
+ let reportID = SearchUIUtils . isTransactionListItemType ( item ) && ( ! item . isFromOneTransactionReport || isFromSelfDM ) ? item . transactionThreadReportID : item . reportID ;
326
327
327
328
if ( ! reportID ) {
328
329
return ;
329
330
}
330
331
331
332
// If we're trying to open a legacy transaction without a transaction thread, let's create the thread and navigate the user
332
- if ( SearchUtils . isTransactionListItemType ( item ) && reportID === '0' && item . moneyRequestReportActionID ) {
333
+ if ( SearchUIUtils . isTransactionListItemType ( item ) && reportID === '0' && item . moneyRequestReportActionID ) {
333
334
reportID = ReportUtils . generateReportID ( ) ;
334
335
SearchActions . createTransactionThread ( hash , item . transactionID , reportID , item . moneyRequestReportActionID ) ;
335
336
}
336
337
337
338
const backTo = Navigation . getActiveRoute ( ) ;
338
339
339
- if ( SearchUtils . isReportActionListItemType ( item ) ) {
340
+ if ( SearchUIUtils . isReportActionListItemType ( item ) ) {
340
341
const reportActionID = item . reportActionID ;
341
342
Navigation . navigate ( ROUTES . SEARCH_REPORT . getRoute ( { reportID, reportActionID, backTo} ) ) ;
342
343
return ;
@@ -372,11 +373,11 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
372
373
} ;
373
374
374
375
const onSortPress = ( column : SearchColumnType , order : SortOrder ) => {
375
- const newQuery = SearchUtils . buildSearchQueryString ( { ...queryJSON , sortBy : column , sortOrder : order } ) ;
376
+ const newQuery = SearchQueryUtils . buildSearchQueryString ( { ...queryJSON , sortBy : column , sortOrder : order } ) ;
376
377
navigation . setParams ( { q : newQuery } ) ;
377
378
} ;
378
379
379
- const shouldShowYear = SearchUtils . shouldShowYear ( searchResults ?. data ) ;
380
+ const shouldShowYear = SearchUIUtils . shouldShowYear ( searchResults ?. data ) ;
380
381
const shouldShowSorting = sortableSearchStatuses . includes ( status ) ;
381
382
382
383
return (
@@ -401,7 +402,7 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
401
402
)
402
403
}
403
404
isSelected = { ( item ) =>
404
- status !== CONST . SEARCH . STATUS . EXPENSE . ALL && SearchUtils . isReportListItemType ( item )
405
+ status !== CONST . SEARCH . STATUS . EXPENSE . ALL && SearchUIUtils . isReportListItemType ( item )
405
406
? item . transactions . some ( ( transaction ) => selectedTransactions [ transaction . keyForList ] ?. isSelected )
406
407
: ! ! item . isSelected
407
408
}
0 commit comments