@@ -17,7 +17,7 @@ import SingleSelectPopup from '@components/Search/FilterDropdowns/SingleSelectPo
1717import UserSelectPopup from '@components/Search/FilterDropdowns/UserSelectPopup' ;
1818import { useSearchContext } from '@components/Search/SearchContext' ;
1919import type { SearchDateValues } from '@components/Search/SearchDatePresetFilterBase' ;
20- import type { SearchDateFilterKeys , SearchQueryJSON , SingularSearchStatus } from '@components/Search/types' ;
20+ import type { SearchDateFilterKeys , SearchGroupBy , SearchQueryJSON , SingularSearchStatus } from '@components/Search/types' ;
2121import SearchFiltersSkeleton from '@components/Skeletons/SearchFiltersSkeleton' ;
2222import useEnvironment from '@hooks/useEnvironment' ;
2323import useLocalize from '@hooks/useLocalize' ;
@@ -40,7 +40,7 @@ import {
4040 isFilterSupported ,
4141 isSearchDatePreset ,
4242} from '@libs/SearchQueryUtils' ;
43- import { getDatePresets , getFeedOptions , getGroupByOptions , getStatusOptions , getTypeOptions } from '@libs/SearchUIUtils' ;
43+ import { getDatePresets , getFeedOptions , getGroupByOptions , getStatusOptions , getTypeOptions , getWithdrawalTypeOptions } from '@libs/SearchUIUtils' ;
4444import CONST from '@src/CONST' ;
4545import type { TranslationPaths } from '@src/languages/types' ;
4646import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -189,6 +189,12 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions, isMobileSelectionMod
189189 [ filterFormValues . withdrawnOn , filterFormValues . withdrawnAfter , filterFormValues . withdrawnBefore , createDateDisplayValue ] ,
190190 ) ;
191191
192+ const [ withdrawalTypeOptions , withdrawalType ] = useMemo ( ( ) => {
193+ const options = getWithdrawalTypeOptions ( translate ) ;
194+ const value = options . find ( ( option ) => option . value === filterFormValues . withdrawalType ) ?? null ;
195+ return [ options , value ] ;
196+ } , [ translate , filterFormValues . withdrawalType ] ) ;
197+
192198 const updateFilterForm = useCallback (
193199 ( values : Partial < SearchAdvancedFiltersForm > ) => {
194200 const updatedFilterFormValues : Partial < SearchAdvancedFiltersForm > = {
@@ -296,6 +302,21 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions, isMobileSelectionMod
296302 [ createDatePickerComponent , withdrawn ] ,
297303 ) ;
298304
305+ const withdrawalTypeComponent = useCallback (
306+ ( { closeOverlay} : PopoverComponentProps ) => {
307+ return (
308+ < SingleSelectPopup
309+ label = { translate ( 'search.withdrawalType' ) }
310+ items = { withdrawalTypeOptions }
311+ value = { withdrawalType }
312+ closeOverlay = { closeOverlay }
313+ onChange = { ( item ) => updateFilterForm ( { withdrawalType : item ?. value } ) }
314+ />
315+ ) ;
316+ } ,
317+ [ translate , withdrawalTypeOptions , withdrawalType , updateFilterForm ] ,
318+ ) ;
319+
299320 const statusComponent = useCallback (
300321 ( { closeOverlay} : PopoverComponentProps ) => {
301322 const onChange = ( selectedItems : Array < MultiSelectItem < SingularSearchStatus > > ) => {
@@ -366,6 +387,8 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions, isMobileSelectionMod
366387 const shouldDisplayGroupByFilter = isDevelopment ;
367388 const shouldDisplayFeedFilter = feedOptions . length > 1 && ! ! filterFormValues . feed ;
368389 const shouldDisplayPostedFilter = ! ! filterFormValues . feed && ( ! ! filterFormValues . postedOn || ! ! filterFormValues . postedAfter || ! ! filterFormValues . postedBefore ) ;
390+ // We'll refactor this to use a const in https://github.com/Expensify/App/issues/68227
391+ const shouldDisplayWithdrawalTypeFilter = groupBy ?. value === ( 'withdrawalID' as SearchGroupBy ) && ! ! filterFormValues . withdrawalType ;
369392 const shouldDisplayWithdrawnFilter = ! ! filterFormValues . withdrawnOn || ! ! filterFormValues . withdrawnAfter || ! ! filterFormValues . withdrawnBefore ;
370393
371394 const filterList = [
@@ -405,6 +428,16 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions, isMobileSelectionMod
405428 } ,
406429 ]
407430 : [ ] ) ,
431+ ...( shouldDisplayWithdrawalTypeFilter
432+ ? [
433+ {
434+ label : translate ( 'search.withdrawalType' ) ,
435+ PopoverComponent : withdrawalTypeComponent ,
436+ value : withdrawalType ?. text ?? null ,
437+ filterKey : FILTER_KEYS . WITHDRAWAL_TYPE ,
438+ } ,
439+ ]
440+ : [ ] ) ,
408441 ...( shouldDisplayWithdrawnFilter
409442 ? [
410443 {
@@ -439,6 +472,7 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions, isMobileSelectionMod
439472 } , [
440473 type ,
441474 groupBy ,
475+ withdrawalType ,
442476 displayDate ,
443477 displayPosted ,
444478 displayWithdrawn ,
@@ -447,6 +481,7 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions, isMobileSelectionMod
447481 filterFormValues . postedOn ,
448482 filterFormValues . postedAfter ,
449483 filterFormValues . postedBefore ,
484+ filterFormValues . withdrawalType ,
450485 filterFormValues . withdrawnOn ,
451486 filterFormValues . withdrawnAfter ,
452487 filterFormValues . withdrawnBefore ,
@@ -457,6 +492,7 @@ function SearchFiltersBar({queryJSON, headerButtonsOptions, isMobileSelectionMod
457492 datePickerComponent ,
458493 userPickerComponent ,
459494 postedPickerComponent ,
495+ withdrawalTypeComponent ,
460496 withdrawnPickerComponent ,
461497 status ,
462498 personalDetails ,
0 commit comments