diff --git a/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx b/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx index bc887099729f..3933677def01 100644 --- a/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx +++ b/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx @@ -4,7 +4,9 @@ import {emailSelector} from '@selectors/Session'; import {searchResultsErrorSelector} from '@selectors/Snapshot'; import React, {useCallback, useContext, useEffect, useMemo, useRef} from 'react'; import type {ReactNode} from 'react'; -import {FlatList, View} from 'react-native'; +import {View} from 'react-native'; +// eslint-disable-next-line no-restricted-imports +import type {ScrollView as RNScrollView} from 'react-native'; import Button from '@components/Button'; import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu'; import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types'; @@ -13,6 +15,7 @@ import {KYCWallContext} from '@components/KYCWall/KYCWallContext'; import type {PaymentMethodType} from '@components/KYCWall/types'; import {LockedAccountContext} from '@components/LockedAccountModalProvider'; import {usePersonalDetails} from '@components/OnyxListItemProvider'; +import ScrollView from '@components/ScrollView'; import type {SearchDateValues} from '@components/Search/FilterComponents/DatePresetFilterBase'; import DateSelectPopup from '@components/Search/FilterDropdowns/DateSelectPopup'; import type {PopoverComponentProps} from '@components/Search/FilterDropdowns/DropdownButton'; @@ -45,7 +48,6 @@ import {getActiveAdminWorkspaces, getAllTaxRates, isPaidGroupPolicy} from '@libs import {isExpenseReport} from '@libs/ReportUtils'; import {buildFilterFormValuesFromQuery, buildQueryStringFromFilterFormValues, isFilterSupported, isSearchDatePreset} from '@libs/SearchQueryUtils'; import {getDatePresets, getFeedOptions, getGroupByOptions, getGroupCurrencyOptions, getHasOptions, getStatusOptions, getTypeOptions, getWithdrawalTypeOptions} from '@libs/SearchUIUtils'; -import shouldAdjustScroll from '@libs/shouldAdjustScroll'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -84,7 +86,7 @@ function SearchFiltersBar({ latestBankItems, }: SearchFiltersBarProps) { const isFocused = useIsFocused(); - const scrollRef = useRef>(null); + const scrollRef = useRef(null); const currentPolicy = usePolicy(currentSelectedPolicyID); const [isUserValidated] = useOnyx(ONYXKEYS.ACCOUNT, {selector: isUserValidatedSelector, canBeMissing: true}); // type, groupBy and status values are not guaranteed to respect the ts type as they come from user input @@ -730,60 +732,6 @@ function SearchFiltersBar({ }); }, [filterFormValues, filters, typeFiltersKeys]); - const prevFiltersLength = useRef(0); - - useEffect(() => { - return () => { - prevFiltersLength.current = filters.length; - }; - }, [filters.length]); - - const adjustScroll = useCallback(() => { - // Workaround for a known React Native bug on Android (https://github.com/facebook/react-native/issues/27504): - // When the FlatList is scrolled to the end and the last item is changed, a blank space is left behind. - // To fix this, we detect when onEndReached is triggered due to an item deletion, - // and programmatically scroll to the end to fill the space. - if (!shouldAdjustScroll) { - return; - } - prevFiltersLength.current = filters.length; - scrollRef.current?.scrollToEnd(); - }, [filters.length]); - - const renderFilterItem = useCallback( - // eslint-disable-next-line react/no-unused-prop-types - ({item}: {item: FilterItem}) => ( - - ), - [], - ); - - const filterButtonText = useMemo( - () => translate('search.filtersHeader') + (hiddenSelectedFilters.length > 0 ? ` (${hiddenSelectedFilters.length})` : ''), - [translate, hiddenSelectedFilters.length], - ); - - const renderListFooter = useCallback( - () => ( -