@@ -17,9 +17,10 @@ import useLocalize from '@hooks/useLocalize';
17
17
import usePolicy from '@hooks/usePolicy' ;
18
18
import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
19
19
import useThemeStyles from '@hooks/useThemeStyles' ;
20
- import * as CardUtils from '@libs/CardUtils' ;
21
- import * as OptionsListUtils from '@libs/OptionsListUtils' ;
22
- import type { SearchOption } from '@libs/OptionsListUtils' ;
20
+ import { searchInServer } from '@libs/actions/Report' ;
21
+ import { getCardDescription , isCard , isCardIssued , mergeCardListWithWorkspaceFeeds } from '@libs/CardUtils' ;
22
+ import { combineOrderingOfReportsAndPersonalDetails , getSearchOptions , getValidOptions } from '@libs/OptionsListUtils' ;
23
+ import type { Options , SearchOption } from '@libs/OptionsListUtils' ;
23
24
import Performance from '@libs/Performance' ;
24
25
import { getAllTaxRates } from '@libs/PolicyUtils' ;
25
26
import type { OptionData } from '@libs/ReportUtils' ;
@@ -29,11 +30,10 @@ import {
29
30
getAutocompleteRecentTags ,
30
31
getAutocompleteTags ,
31
32
getAutocompleteTaxList ,
33
+ getQueryWithoutAutocompletedPart ,
32
34
parseForAutocomplete ,
33
35
} from '@libs/SearchAutocompleteUtils' ;
34
- import * as SearchAutocompleteUtils from '@libs/SearchAutocompleteUtils' ;
35
- import * as SearchQueryUtils from '@libs/SearchQueryUtils' ;
36
- import * as ReportUserActions from '@userActions/Report' ;
36
+ import { buildSearchQueryJSON , buildUserReadableQueryString , sanitizeSearchValue } from '@libs/SearchQueryUtils' ;
37
37
import Timing from '@userActions/Timing' ;
38
38
import CONST from '@src/CONST' ;
39
39
import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -47,7 +47,7 @@ type AutocompleteItemData = {
47
47
mapKey ?: SearchFilterKey ;
48
48
} ;
49
49
50
- type GetAdditionalSectionsCallback = ( options : OptionsListUtils . Options ) => Array < SectionListDataType < OptionData | SearchQueryItem > > | undefined ;
50
+ type GetAdditionalSectionsCallback = ( options : Options ) => Array < SectionListDataType < OptionData | SearchQueryItem > > | undefined ;
51
51
52
52
type SearchRouterListProps = {
53
53
/** Value of TextInput */
@@ -139,7 +139,7 @@ function SearchRouterList(
139
139
if ( ! areOptionsInitialized ) {
140
140
return defaultListOptions ;
141
141
}
142
- return OptionsListUtils . getSearchOptions ( options , betas ?? [ ] ) ;
142
+ return getSearchOptions ( options , betas ?? [ ] ) ;
143
143
} , [ areOptionsInitialized , betas , options ] ) ;
144
144
145
145
const [ isInitialRender , setIsInitialRender ] = useState ( true ) ;
@@ -150,15 +150,15 @@ function SearchRouterList(
150
150
151
151
const [ userCardList = { } ] = useOnyx ( ONYXKEYS . CARD_LIST ) ;
152
152
const [ workspaceCardFeeds = { } ] = useOnyx ( ONYXKEYS . COLLECTION . WORKSPACE_CARDS_LIST ) ;
153
- const allCards = useMemo ( ( ) => CardUtils . mergeCardListWithWorkspaceFeeds ( workspaceCardFeeds , userCardList ) , [ userCardList , workspaceCardFeeds ] ) ;
153
+ const allCards = useMemo ( ( ) => mergeCardListWithWorkspaceFeeds ( workspaceCardFeeds , userCardList ) , [ userCardList , workspaceCardFeeds ] ) ;
154
154
const cardAutocompleteList = Object . values ( allCards ) ;
155
155
156
156
const participantsAutocompleteList = useMemo ( ( ) => {
157
157
if ( ! areOptionsInitialized ) {
158
158
return [ ] ;
159
159
}
160
160
161
- const filteredOptions = OptionsListUtils . getValidOptions (
161
+ const filteredOptions = getValidOptions (
162
162
{
163
163
reports : options . reports ,
164
164
personalDetails : options . personalDetails ,
@@ -338,17 +338,14 @@ function SearchRouterList(
338
338
}
339
339
case CONST . SEARCH . SYNTAX_FILTER_KEYS . CARD_ID : {
340
340
const filteredCards = cardAutocompleteList
341
- . filter ( ( card ) => CardUtils . isCard ( card ) && CardUtils . isCardIssued ( card ) )
342
- . filter (
343
- ( card ) =>
344
- card . bank . toLowerCase ( ) . includes ( autocompleteValue . toLowerCase ( ) ) && ! alreadyAutocompletedKeys . includes ( CardUtils . getCardDescription ( card . cardID ) . toLowerCase ( ) ) ,
345
- )
341
+ . filter ( ( card ) => isCard ( card ) && isCardIssued ( card ) )
342
+ . filter ( ( card ) => card . bank . toLowerCase ( ) . includes ( autocompleteValue . toLowerCase ( ) ) && ! alreadyAutocompletedKeys . includes ( getCardDescription ( card . cardID ) . toLowerCase ( ) ) )
346
343
. sort ( )
347
344
. slice ( 0 , 10 ) ;
348
345
349
346
return filteredCards . map ( ( card ) => ( {
350
347
filterKey : CONST . SEARCH . SEARCH_USER_FRIENDLY_KEYS . CARD_ID ,
351
- text : CardUtils . getCardDescription ( card . cardID , allCards ) ,
348
+ text : getCardDescription ( card . cardID , allCards ) ,
352
349
autocompleteID : card . cardID . toString ( ) ,
353
350
mapKey : CONST . SEARCH . SYNTAX_FILTER_KEYS . CARD_ID ,
354
351
} ) ) ;
@@ -380,9 +377,9 @@ function SearchRouterList(
380
377
} , [ recentSearches ] ) ;
381
378
382
379
const recentSearchesData = sortedRecentSearches ?. slice ( 0 , 5 ) . map ( ( { query, timestamp} ) => {
383
- const searchQueryJSON = SearchQueryUtils . buildSearchQueryJSON ( query ) ;
380
+ const searchQueryJSON = buildSearchQueryJSON ( query ) ;
384
381
return {
385
- text : searchQueryJSON ? SearchQueryUtils . buildUserReadableQueryString ( searchQueryJSON , personalDetails , reports , taxRates , allCards ) : query ,
382
+ text : searchQueryJSON ? buildUserReadableQueryString ( searchQueryJSON , personalDetails , reports , taxRates , allCards ) : query ,
386
383
singleIcon : Expensicons . History ,
387
384
searchQuery : query ,
388
385
keyForList : timestamp ,
@@ -402,7 +399,7 @@ function SearchRouterList(
402
399
403
400
Timing . start ( CONST . TIMING . SEARCH_FILTER_OPTIONS ) ;
404
401
const filteredOptions = filterOptions ( autocompleteQueryValue ) ;
405
- const orderedOptions = OptionsListUtils . combineOrderingOfReportsAndPersonalDetails ( filteredOptions , autocompleteQueryValue , {
402
+ const orderedOptions = combineOrderingOfReportsAndPersonalDetails ( filteredOptions , autocompleteQueryValue , {
406
403
sortByReportTypeInSearch : true ,
407
404
preferChatroomsOverThreads : true ,
408
405
} ) ;
@@ -416,7 +413,7 @@ function SearchRouterList(
416
413
} , [ autocompleteQueryValue , filterOptions , searchOptions ] ) ;
417
414
418
415
useEffect ( ( ) => {
419
- ReportUserActions . searchInServer ( autocompleteQueryValue . trim ( ) ) ;
416
+ searchInServer ( autocompleteQueryValue . trim ( ) ) ;
420
417
} , [ autocompleteQueryValue ] ) ;
421
418
422
419
/* Sections generation */
@@ -463,8 +460,8 @@ function SearchRouterList(
463
460
return ;
464
461
}
465
462
466
- const trimmedUserSearchQuery = SearchAutocompleteUtils . getQueryWithoutAutocompletedPart ( autocompleteQueryValue ) ;
467
- setTextQuery ( `${ trimmedUserSearchQuery } ${ SearchQueryUtils . sanitizeSearchValue ( focusedItem . searchQuery ) } ` ) ;
463
+ const trimmedUserSearchQuery = getQueryWithoutAutocompletedPart ( autocompleteQueryValue ) ;
464
+ setTextQuery ( `${ trimmedUserSearchQuery } ${ sanitizeSearchValue ( focusedItem . searchQuery ) } ` ) ;
468
465
updateAutocompleteSubstitutions ( focusedItem ) ;
469
466
} ,
470
467
[ autocompleteQueryValue , setTextQuery , updateAutocompleteSubstitutions ] ,
0 commit comments