@@ -27,88 +27,87 @@ import type {CardList, PersonalDetailsList} from '@src/types/onyx';
27
27
28
28
const baseFilterConfig = {
29
29
date : {
30
- title : getFilterDisplayTitle ,
30
+ getTitle : getFilterDisplayTitle ,
31
31
description : 'common.date' as const ,
32
32
route : ROUTES . SEARCH_ADVANCED_FILTERS_DATE ,
33
33
} ,
34
34
currency : {
35
- title : getFilterDisplayTitle ,
35
+ getTitle : getFilterDisplayTitle ,
36
36
description : 'common.currency' as const ,
37
37
route : ROUTES . SEARCH_ADVANCED_FILTERS_CURRENCY ,
38
38
} ,
39
39
merchant : {
40
- title : getFilterDisplayTitle ,
40
+ getTitle : getFilterDisplayTitle ,
41
41
description : 'common.merchant' as const ,
42
42
route : ROUTES . SEARCH_ADVANCED_FILTERS_MERCHANT ,
43
43
} ,
44
44
description : {
45
- title : getFilterDisplayTitle ,
45
+ getTitle : getFilterDisplayTitle ,
46
46
description : 'common.description' as const ,
47
47
route : ROUTES . SEARCH_ADVANCED_FILTERS_DESCRIPTION ,
48
48
} ,
49
49
reportID : {
50
- title : getFilterDisplayTitle ,
50
+ getTitle : getFilterDisplayTitle ,
51
51
description : 'common.reportID' as const ,
52
52
route : ROUTES . SEARCH_ADVANCED_FILTERS_REPORT_ID ,
53
53
} ,
54
54
amount : {
55
- title : getFilterDisplayTitle ,
55
+ getTitle : getFilterDisplayTitle ,
56
56
description : 'common.total' as const ,
57
57
route : ROUTES . SEARCH_ADVANCED_FILTERS_AMOUNT ,
58
58
} ,
59
59
category : {
60
- title : getFilterDisplayTitle ,
60
+ getTitle : getFilterDisplayTitle ,
61
61
description : 'common.category' as const ,
62
62
route : ROUTES . SEARCH_ADVANCED_FILTERS_CATEGORY ,
63
63
} ,
64
64
keyword : {
65
- title : getFilterDisplayTitle ,
65
+ getTitle : getFilterDisplayTitle ,
66
66
description : 'search.filters.hasKeywords' as const ,
67
67
route : ROUTES . SEARCH_ADVANCED_FILTERS_KEYWORD ,
68
68
} ,
69
69
cardID : {
70
- title : getFilterCardDisplayTitle ,
70
+ getTitle : getFilterCardDisplayTitle ,
71
71
description : 'common.card' as const ,
72
72
route : ROUTES . SEARCH_ADVANCED_FILTERS_CARD ,
73
- shouldHide : ( cards : CardList ) => Object . keys ( cards ) . length === 0 ,
74
73
} ,
75
74
taxRate : {
76
- title : getFilterTaxRateDisplayTitle ,
75
+ getTitle : getFilterTaxRateDisplayTitle ,
77
76
description : 'workspace.taxes.taxRate' as const ,
78
77
route : ROUTES . SEARCH_ADVANCED_FILTERS_TAX_RATE ,
79
78
} ,
80
79
expenseType : {
81
- title : getExpenseTypeDisplayTitle ,
80
+ getTitle : getExpenseTypeDisplayTitle ,
82
81
description : 'search.expenseType' as const ,
83
82
route : ROUTES . SEARCH_ADVANCED_FILTERS_EXPENSE_TYPE ,
84
83
} ,
85
84
tag : {
86
- title : getFilterDisplayTitle ,
85
+ getTitle : getFilterDisplayTitle ,
87
86
description : 'common.tag' as const ,
88
87
route : ROUTES . SEARCH_ADVANCED_FILTERS_TAG ,
89
88
} ,
90
89
from : {
91
- title : getFilterParticipantDisplayTitle ,
90
+ getTitle : getFilterParticipantDisplayTitle ,
92
91
description : 'common.from' as const ,
93
92
route : ROUTES . SEARCH_ADVANCED_FILTERS_FROM ,
94
93
} ,
95
94
to : {
96
- title : getFilterParticipantDisplayTitle ,
95
+ getTitle : getFilterParticipantDisplayTitle ,
97
96
description : 'common.to' as const ,
98
97
route : ROUTES . SEARCH_ADVANCED_FILTERS_TO ,
99
98
} ,
100
99
has : {
101
- title : getFilterHasDisplayTitle ,
100
+ getTitle : getFilterHasDisplayTitle ,
102
101
description : 'search.filters.has' as const ,
103
102
route : ROUTES . SEARCH_ADVANCED_FILTERS_HAS ,
104
103
} ,
105
104
} ;
106
105
107
106
const typeFiltersKeys : Record < string , Array < ValueOf < typeof CONST . SEARCH . SYNTAX_FILTER_KEYS > > > = {
108
- [ CONST . SEARCH . DATA_TYPES . EXPENSE ] : [ 'date' , 'currency' , 'merchant' , 'description' , 'reportID' , 'amount' , 'category' , 'keyword' , 'taxRate' , 'expenseType' , 'tag' , 'from' , 'to' ] ,
109
- [ CONST . SEARCH . DATA_TYPES . INVOICE ] : [ 'date' , 'currency' , 'merchant' , 'description' , 'reportID' , 'amount' , 'category' , 'keyword' , 'taxRate' , 'tag' , 'from' , 'to' ] ,
110
- [ CONST . SEARCH . DATA_TYPES . TRIP ] : [ 'date' , 'currency' , 'merchant' , 'description' , 'reportID' , 'amount' , 'category' , 'keyword' , 'taxRate' , 'tag' , 'from' , 'to' ] ,
111
- [ CONST . SEARCH . DATA_TYPES . CHAT ] : [ 'date' , 'keyword' , 'from' , 'to' , ' has'] ,
107
+ [ CONST . SEARCH . DATA_TYPES . EXPENSE ] : [ 'date' , 'currency' , 'merchant' , 'description' , 'reportID' , 'amount' , 'category' , 'keyword' , 'taxRate' , 'expenseType' , 'tag' , 'from' , 'to' , 'cardID' ] ,
108
+ [ CONST . SEARCH . DATA_TYPES . INVOICE ] : [ 'date' , 'currency' , 'merchant' , 'description' , 'reportID' , 'amount' , 'category' , 'keyword' , 'taxRate' , 'tag' , 'from' , 'to' , 'cardID' ] ,
109
+ [ CONST . SEARCH . DATA_TYPES . TRIP ] : [ 'date' , 'currency' , 'merchant' , 'description' , 'reportID' , 'amount' , 'category' , 'keyword' , 'taxRate' , 'tag' , 'from' , 'to' , 'cardID' ] ,
110
+ [ CONST . SEARCH . DATA_TYPES . CHAT ] : [ 'date' , 'keyword' , 'from' , 'has' ] ,
112
111
} ;
113
112
114
113
function getFilterCardDisplayTitle ( filters : Partial < SearchAdvancedFiltersForm > , cards : CardList ) {
@@ -260,15 +259,18 @@ function AdvancedSearchFilters() {
260
259
key === CONST . SEARCH . SYNTAX_FILTER_KEYS . KEYWORD ||
261
260
key === CONST . SEARCH . SYNTAX_FILTER_KEYS . TAG
262
261
) {
263
- filterTitle = baseFilterConfig [ key ] . title ( searchAdvancedFilters , key , translate ) ;
262
+ filterTitle = baseFilterConfig [ key ] . getTitle ( searchAdvancedFilters , key , translate ) ;
264
263
} else if ( key === CONST . SEARCH . SYNTAX_FILTER_KEYS . CARD_ID ) {
265
- filterTitle = baseFilterConfig [ key ] . title ( searchAdvancedFilters , cardList ) ;
264
+ if ( Object . keys ( cardList ) . length === 0 ) {
265
+ return undefined ;
266
+ }
267
+ filterTitle = baseFilterConfig [ key ] . getTitle ( searchAdvancedFilters , cardList ) ;
266
268
} else if ( key === CONST . SEARCH . SYNTAX_FILTER_KEYS . TAX_RATE ) {
267
- filterTitle = baseFilterConfig [ key ] . title ( searchAdvancedFilters , taxRates ) ;
269
+ filterTitle = baseFilterConfig [ key ] . getTitle ( searchAdvancedFilters , taxRates ) ;
268
270
} else if ( key === CONST . SEARCH . SYNTAX_FILTER_KEYS . EXPENSE_TYPE || key === CONST . SEARCH . SYNTAX_FILTER_KEYS . HAS ) {
269
- filterTitle = baseFilterConfig [ key ] . title ( searchAdvancedFilters , translate ) ;
271
+ filterTitle = baseFilterConfig [ key ] . getTitle ( searchAdvancedFilters , translate ) ;
270
272
} else if ( key === CONST . SEARCH . SYNTAX_FILTER_KEYS . FROM || key === CONST . SEARCH . SYNTAX_FILTER_KEYS . TO ) {
271
- filterTitle = baseFilterConfig [ key ] . title ( searchAdvancedFilters [ key ] ?? [ ] , personalDetails ) ;
273
+ filterTitle = baseFilterConfig [ key ] . getTitle ( searchAdvancedFilters [ key ] ?? [ ] , personalDetails ) ;
272
274
}
273
275
return {
274
276
key,
@@ -283,6 +285,9 @@ function AdvancedSearchFilters() {
283
285
< ScrollView contentContainerStyle = { [ styles . flexGrow1 , styles . justifyContentBetween ] } >
284
286
< View >
285
287
{ filters . map ( ( filter ) => {
288
+ if ( filter === undefined ) {
289
+ return undefined ;
290
+ }
286
291
return (
287
292
< MenuItemWithTopDescription
288
293
key = { filter . description }
0 commit comments