@@ -4,7 +4,7 @@ import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
44import type { NativeScrollEvent , NativeSyntheticEvent , StyleProp , ViewStyle } from 'react-native' ;
55import { View } from 'react-native' ;
66import type { OnyxEntry } from 'react-native-onyx' ;
7- import Animated , { FadeIn , FadeOut , useAnimatedStyle , useSharedValue , withTiming } from 'react-native-reanimated' ;
7+ import Animated , { useAnimatedStyle , useSharedValue , withTiming } from 'react-native-reanimated' ;
88import FullPageErrorView from '@components/BlockingViews/FullPageErrorView' ;
99import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView' ;
1010import { ModalActions } from '@components/Modal/Global/ModalContext' ;
@@ -36,7 +36,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
3636import { openOldDotLink } from '@libs/actions/Link' ;
3737import { turnOffMobileSelectionMode , turnOnMobileSelectionMode } from '@libs/actions/MobileSelectionMode' ;
3838import type { TransactionPreviewData } from '@libs/actions/Search' ;
39- import { openSearch , setOptimisticDataForTransactionThreadPreview } from '@libs/actions/Search' ;
39+ import { setOptimisticDataForTransactionThreadPreview } from '@libs/actions/Search' ;
4040import { canUseTouchScreen } from '@libs/DeviceCapabilities' ;
4141import Log from '@libs/Log' ;
4242import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute' ;
@@ -51,6 +51,7 @@ import {
5151 getListItem ,
5252 getSections ,
5353 getSortedSections ,
54+ getValidGroupBy ,
5455 getWideAmountIndicators ,
5556 isGroupedItemArray ,
5657 isReportActionListItemType ,
@@ -229,7 +230,6 @@ function Search({
229230 const navigation = useNavigation < PlatformStackNavigationProp < SearchFullscreenNavigatorParamList > > ( ) ;
230231 const isFocused = useIsFocused ( ) ;
231232 const { markReportIDAsExpense} = useWideRHPActions ( ) ;
232-
233233 const {
234234 currentSearchHash,
235235 currentSearchKey,
@@ -241,7 +241,6 @@ function Search({
241241 shouldUseLiveData,
242242 suggestedSearches,
243243 } = useSearchStateContext ( ) ;
244-
245244 const { setSelectedTransactions, clearSelectedTransactions, setShouldShowFiltersBarLoading, setShouldShowSelectAllMatchingItems, selectAllMatchingItems, setShouldResetSearchQuery} =
246245 useSearchActionsContext ( ) ;
247246 const [ offset , setOffset ] = useState ( 0 ) ;
@@ -306,7 +305,7 @@ function Search({
306305 }
307306 } , [ onDEWModalOpen , showConfirmModal , translate ] ) ;
308307
309- const validGroupBy = groupBy && Object . values ( CONST . SEARCH . GROUP_BY ) . includes ( groupBy ) ? groupBy : undefined ;
308+ const validGroupBy = getValidGroupBy ( groupBy ) ;
310309 const prevValidGroupBy = usePrevious ( validGroupBy ) ;
311310 const isSearchResultsEmpty = ! searchResults ?. data || isSearchResultsEmptyUtil ( searchResults , validGroupBy ) ;
312311
@@ -354,17 +353,6 @@ function Search({
354353 // eslint-disable-next-line react-hooks/exhaustive-deps
355354 } , [ isSmallScreenWidth ] ) ;
356355
357- useEffect ( ( ) => {
358- openSearch ( { includePartiallySetupBankAccounts : true } ) ;
359- } , [ ] ) ;
360-
361- useEffect ( ( ) => {
362- if ( ! prevIsOffline || isOffline ) {
363- return ;
364- }
365- openSearch ( { includePartiallySetupBankAccounts : true } ) ;
366- } , [ isOffline , prevIsOffline ] ) ;
367-
368356 const { newSearchResultKeys, handleSelectionListScroll, newTransactions} = useSearchHighlightAndScroll ( {
369357 searchResults,
370358 transactions,
@@ -449,21 +437,6 @@ function Search({
449437
450438 const shouldShowLoadingMoreItems = ! shouldShowLoadingState && searchResults ?. search ?. isLoading && searchResults ?. search ?. offset > 0 ;
451439
452- const loadingSkeletonReasonAttributes = useMemo < SkeletonSpanReasonAttributes > (
453- ( ) => ( {
454- context : 'Search' ,
455- isOffline,
456- isDataLoaded,
457- isCardFeedsLoading,
458- isSearchLoading : ! ! searchResults ?. search ?. isLoading ,
459- hasEmptyData : Array . isArray ( searchResults ?. data ) && searchResults ?. data . length === 0 ,
460- hasErrors,
461- hasPendingResponse : searchRequestResponseStatusCode === null ,
462- shouldUseLiveData,
463- } ) ,
464- [ isOffline , isDataLoaded , isCardFeedsLoading , searchResults ?. search ?. isLoading , searchResults ?. data , hasErrors , searchRequestResponseStatusCode , shouldUseLiveData ] ,
465- ) ;
466-
467440 const loadMoreSkeletonReasonAttributes = useMemo < SkeletonSpanReasonAttributes > (
468441 ( ) => ( {
469442 context : 'Search.ListFooter' ,
@@ -1333,11 +1306,6 @@ function Search({
13331306 spanExistedOnMount . current = false ;
13341307 } , [ ] ) ;
13351308
1336- const onLayoutSkeleton = useCallback ( ( ) => {
1337- hasHadFirstLayout . current = true ;
1338- endSpanWithAttributes ( CONST . TELEMETRY . SPAN_NAVIGATE_TO_REPORTS , { [ CONST . TELEMETRY . ATTRIBUTE_IS_WARM ] : false } ) ;
1339- } , [ ] ) ;
1340-
13411309 const onLayoutChart = useCallback ( ( ) => {
13421310 hasHadFirstLayout . current = true ;
13431311 endSpanWithAttributes ( CONST . TELEMETRY . SPAN_NAVIGATE_TO_REPORTS , { [ CONST . TELEMETRY . ATTRIBUTE_IS_WARM ] : true } ) ;
@@ -1362,23 +1330,6 @@ function Search({
13621330 } , [ shouldShowLoadingState ] ) ,
13631331 ) ;
13641332
1365- if ( shouldShowLoadingState ) {
1366- return (
1367- < Animated . View
1368- entering = { FadeIn . duration ( CONST . SEARCH . ANIMATION . FADE_DURATION ) }
1369- exiting = { FadeOut . duration ( CONST . SEARCH . ANIMATION . FADE_DURATION ) }
1370- style = { [ styles . flex1 ] }
1371- onLayout = { onLayoutSkeleton }
1372- >
1373- < SearchRowSkeleton
1374- shouldAnimate
1375- containerStyle = { shouldUseNarrowLayout ? styles . searchListContentContainerStyles : styles . mt3 }
1376- reasonAttributes = { loadingSkeletonReasonAttributes }
1377- />
1378- </ Animated . View >
1379- ) ;
1380- }
1381-
13821333 if ( searchResults === undefined ) {
13831334 Log . alert ( '[Search] Undefined search type' ) ;
13841335 cancelNavigationSpans ( ) ;
0 commit comments