@@ -14,6 +14,7 @@ import useOnyx from '@hooks/useOnyx';
1414import usePrevious from '@hooks/usePrevious' ;
1515import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
1616import useSearchHighlightAndScroll from '@hooks/useSearchHighlightAndScroll' ;
17+ import useSearchTypeMenuSections from '@hooks/useSearchTypeMenuSections' ;
1718import useThemeStyles from '@hooks/useThemeStyles' ;
1819import { turnOffMobileSelectionMode , turnOnMobileSelectionMode } from '@libs/actions/MobileSelectionMode' ;
1920import { openSearch , updateSearchResultsWithTransactionThreadReportID } from '@libs/actions/Search' ;
@@ -23,7 +24,7 @@ import Log from '@libs/Log';
2324import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute' ;
2425import type { PlatformStackNavigationProp } from '@libs/Navigation/PlatformStackNavigation/types' ;
2526import Performance from '@libs/Performance' ;
26- import { getIOUActionForTransactionID } from '@libs/ReportActionsUtils' ;
27+ import { getIOUActionForTransactionID , isExportIntegrationAction , isIntegrationMessageAction } from '@libs/ReportActionsUtils' ;
2728import { canEditFieldOfMoneyRequest , generateReportID } from '@libs/ReportUtils' ;
2829import { buildSearchQueryString } from '@libs/SearchQueryUtils' ;
2930import {
@@ -163,9 +164,24 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
163164
164165 const { type, status, sortBy, sortOrder, hash, groupBy} = queryJSON ;
165166
167+ const { currentSearch} = useSearchTypeMenuSections ( hash ) ;
166168 const [ transactions ] = useOnyx ( ONYXKEYS . COLLECTION . TRANSACTION , { canBeMissing : true } ) ;
167169 const previousTransactions = usePrevious ( transactions ) ;
168170 const [ reportActions ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT_ACTIONS , { canBeMissing : true } ) ;
171+ // Create a selector for only the reportActions needed to determine if a report has been exported or not, grouped by report
172+ const [ exportReportActions ] = useOnyx ( ONYXKEYS . COLLECTION . REPORT_ACTIONS , {
173+ canEvict : false ,
174+ canBeMissing : true ,
175+ selector : ( allReportActions ) => {
176+ return Object . fromEntries (
177+ Object . entries ( allReportActions ?? { } ) . map ( ( [ reportID , reportActionsGroup ] ) => {
178+ const filteredReportActions = Object . values ( reportActionsGroup ?? { } ) . filter ( ( action ) => isExportIntegrationAction ( action ) || isIntegrationMessageAction ( action ) ) ;
179+ return [ reportID , filteredReportActions ] ;
180+ } ) ,
181+ ) ;
182+ } ,
183+ } ) ;
184+
169185 const previousReportActions = usePrevious ( reportActions ) ;
170186 const reportActionsArray = useMemo (
171187 ( ) =>
@@ -255,8 +271,9 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
255271 if ( searchResults === undefined || ! isDataLoaded ) {
256272 return [ ] ;
257273 }
258- return getSections ( type , status , searchResults . data , searchResults . search , groupBy ) ;
259- } , [ searchResults , isDataLoaded , type , status , groupBy ] ) ;
274+
275+ return getSections ( type , searchResults . data , searchResults . search , groupBy , exportReportActions , currentSearch ?. key ) ;
276+ } , [ currentSearch ?. key , exportReportActions , groupBy , isDataLoaded , searchResults , type ] ) ;
260277
261278 useEffect ( ( ) => {
262279 /** We only want to display the skeleton for the status filters the first time we load them for a specific data type */
0 commit comments