From b6de5dcdb0a1ddc7b78ab73c690bd7f90ad1f3b3 Mon Sep 17 00:00:00 2001 From: Github Date: Tue, 8 Jul 2025 14:52:53 +0200 Subject: [PATCH 1/7] perf: Move remaining useOnyx calls up in the Search component tree --- Mobile-Expensify | 2 +- .../Search/SearchAutocompleteList.tsx | 31 ++++++++++++------- src/components/Search/SearchList.tsx | 3 ++ .../SearchPageHeader/SearchPageHeader.tsx | 4 +++ .../SearchPageHeaderInput.tsx | 10 +++++- .../Search/SearchRouter/SearchRouter.tsx | 17 ++++++++-- src/components/SelectionList/ChatListItem.tsx | 7 +---- .../Search/TransactionGroupListItem.tsx | 6 +--- src/components/SelectionList/types.ts | 4 +++ 9 files changed, 58 insertions(+), 26 deletions(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 32922dcca0de..3c9610642586 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 32922dcca0de2dae6060cfccb1a3a40f1397c68b +Subproject commit 3c9610642586a19c6e12ef1fcadce8015ecb3481 diff --git a/src/components/Search/SearchAutocompleteList.tsx b/src/components/Search/SearchAutocompleteList.tsx index fe737e6dd91c..d423c1d1edce 100644 --- a/src/components/Search/SearchAutocompleteList.tsx +++ b/src/components/Search/SearchAutocompleteList.tsx @@ -1,9 +1,8 @@ import {Str} from 'expensify-common'; import type {ForwardedRef} from 'react'; import React, {forwardRef, useCallback, useEffect, useMemo, useState} from 'react'; -import type {OnyxCollection} from 'react-native-onyx'; +import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import * as Expensicons from '@components/Icon/Expensicons'; -import {usePersonalDetails} from '@components/OnyxProvider'; import {useOptionsList} from '@components/OptionListContextProvider'; import type {AnimatedTextInputRef} from '@components/RNTextInput'; import SelectionList from '@components/SelectionList'; @@ -18,7 +17,7 @@ import useOnyx from '@hooks/useOnyx'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import {getCardFeedsForDisplay} from '@libs/CardFeedUtils'; -import {getCardDescription, isCard, isCardHiddenFromSearch, mergeCardListWithWorkspaceFeeds} from '@libs/CardUtils'; +import {getCardDescription, isCard, isCardHiddenFromSearch} from '@libs/CardUtils'; import Log from '@libs/Log'; import memoize from '@libs/memoize'; import type {Options, SearchOption} from '@libs/OptionsListUtils'; @@ -40,7 +39,7 @@ import StringUtils from '@libs/StringUtils'; import Timing from '@userActions/Timing'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Policy, Report} from '@src/types/onyx'; +import type * as OnyxTypes from '@src/types/onyx'; import type PersonalDetails from '@src/types/onyx/PersonalDetails'; import {getEmptyObject} from '@src/types/utils/EmptyObject'; import {getSubstitutionMapKey} from './SearchRouter/getQueryWithSubstitutions'; @@ -85,6 +84,18 @@ type SearchAutocompleteListProps = { /** Ref for textInput */ textInputRef?: React.RefObject; + + /** Personal details */ + personalDetails: OnyxEntry; + + /** Reports */ + reports: OnyxCollection; + + /** All feeds */ + allFeeds: Record; + + /** All cards */ + allCards: OnyxTypes.CardList; }; const defaultListOptions = { @@ -147,6 +158,10 @@ function SearchAutocompleteList( shouldSubscribeToArrowKeyEvents = true, onHighlightFirstItem, textInputRef, + personalDetails, + reports, + allFeeds, + allCards, }: SearchAutocompleteListProps, ref: ForwardedRef, ) { @@ -156,8 +171,6 @@ function SearchAutocompleteList( const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: true}); const [recentSearches] = useOnyx(ONYXKEYS.RECENT_SEARCHES, {canBeMissing: true}); - const personalDetails = usePersonalDetails(); - const [reports = getEmptyObject>>()] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); const taxRates = getAllTaxRates(); const {options, areOptionsInitialized} = useOptionsList(); @@ -197,11 +210,7 @@ function SearchAutocompleteList( const expenseTypes = Object.values(CONST.SEARCH.TRANSACTION_TYPE); const booleanTypes = Object.values(CONST.SEARCH.BOOLEAN); - const [userCardList] = useOnyx(ONYXKEYS.CARD_LIST, {canBeMissing: true}); - const [workspaceCardFeeds] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, {canBeMissing: true}); - const allCards = useMemo(() => mergeCardListWithWorkspaceFeeds(workspaceCardFeeds ?? CONST.EMPTY_OBJECT, userCardList), [userCardList, workspaceCardFeeds]); - const [allFeeds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {canBeMissing: true}); - const cardAutocompleteList = Object.values(allCards); + const cardAutocompleteList = useMemo(() => Object.values(allCards), [allCards]); const feedAutoCompleteList = useMemo(() => { // We don't want to show the "Expensify Card" feed in the autocomplete suggestion list // Thus passing an empty object to the `allCards` parameter. diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index a7ecf385af49..8e72a0993f8e 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -275,6 +275,8 @@ function SearchList( const isItemFocused = focusedIndex === index; const isItemHighlighted = !!itemsToHighlight?.has(item.keyForList ?? ''); const isDisabled = item.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; + const reportID = Number(item?.reportID ?? CONST.DEFAULT_NUMBER_ID); + const report = allReports?.[reportID]; return ( ); }, diff --git a/src/components/Search/SearchPageHeader/SearchPageHeader.tsx b/src/components/Search/SearchPageHeader/SearchPageHeader.tsx index f14f52478edc..2e5e36f39eff 100644 --- a/src/components/Search/SearchPageHeader/SearchPageHeader.tsx +++ b/src/components/Search/SearchPageHeader/SearchPageHeader.tsx @@ -6,6 +6,10 @@ import type {SearchQueryJSON} from '@components/Search/types'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import SearchSelectedNarrow from '@pages/Search/SearchSelectedNarrow'; import type CONST from '@src/CONST'; +<<<<<<< HEAD +======= +import type MobileSelectionMode from '@src/types/onyx/MobileSelectionMode'; +>>>>>>> 27fc4644c51 (perf: Move remaining useOnyx calls up in the Search component tree) import type DeepValueOf from '@src/types/utils/DeepValueOf'; import SearchPageHeaderInput from './SearchPageHeaderInput'; diff --git a/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx b/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx index 1dbb426b2dce..1bebf75ce3ad 100644 --- a/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx +++ b/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx @@ -61,7 +61,7 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: false}); const taxRates = useMemo(() => getAllTaxRates(), []); const [userCardList] = useOnyx(ONYXKEYS.CARD_LIST, {canBeMissing: true}); - const [workspaceCardFeeds] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, {canBeMissing: true}); + const [workspaceCardFeeds = {}] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, {canBeMissing: true}); const allCards = useMemo(() => mergeCardListWithWorkspaceFeeds(workspaceCardFeeds ?? CONST.EMPTY_OBJECT, userCardList), [userCardList, workspaceCardFeeds]); const [allFeeds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {canBeMissing: true}); const {inputQuery: originalInputQuery} = queryJSON; @@ -387,6 +387,10 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo setTextQuery={setTextAndUpdateSelection} updateAutocompleteSubstitutions={updateAutocompleteSubstitutions} ref={listRef} + personalDetails={personalDetails} + reports={reports} + workspaceCardFeeds={workspaceCardFeeds} + allCards={allCards} /> )} @@ -454,6 +458,10 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo updateAutocompleteSubstitutions={updateAutocompleteSubstitutions} ref={listRef} shouldSubscribeToArrowKeyEvents={isAutocompleteListVisible} + personalDetails={personalDetails} + reports={reports} + workspaceCardFeeds={workspaceCardFeeds} + allCards={allCards} /> diff --git a/src/components/Search/SearchRouter/SearchRouter.tsx b/src/components/Search/SearchRouter/SearchRouter.tsx index ae855804beb9..d2be157384e2 100644 --- a/src/components/Search/SearchRouter/SearchRouter.tsx +++ b/src/components/Search/SearchRouter/SearchRouter.tsx @@ -1,11 +1,12 @@ import {findFocusedRoute, useNavigationState} from '@react-navigation/native'; import {deepEqual} from 'fast-equals'; -import React, {forwardRef, useCallback, useEffect, useRef, useState} from 'react'; +import React, {forwardRef, useCallback, useEffect, useMemo, useRef, useState} from 'react'; import type {TextInputProps} from 'react-native'; import {InteractionManager, Keyboard, View} from 'react-native'; import type {ValueOf} from 'type-fest'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Expensicons from '@components/Icon/Expensicons'; +import {usePersonalDetails} from '@components/OnyxProvider'; import type {AnimatedTextInputRef} from '@components/RNTextInput'; import type {GetAdditionalSectionsCallback} from '@components/Search/SearchAutocompleteList'; import SearchAutocompleteList from '@components/Search/SearchAutocompleteList'; @@ -20,6 +21,7 @@ import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; +import {mergeCardListWithWorkspaceFeeds} from '@libs/CardUtils'; import {scrollToRight} from '@libs/InputUtils'; import Log from '@libs/Log'; import backHistory from '@libs/Navigation/helpers/backHistory'; @@ -36,7 +38,9 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; +import {CardFeeds, WorkspaceCardsList} from '@src/types/onyx'; import type Report from '@src/types/onyx/Report'; +import {getEmptyObject} from '@src/types/utils/EmptyObject'; import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; import type {SubstitutionMap} from './getQueryWithSubstitutions'; import {getQueryWithSubstitutions} from './getQueryWithSubstitutions'; @@ -82,7 +86,12 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla const styles = useThemeStyles(); const [, recentSearchesMetadata] = useOnyx(ONYXKEYS.RECENT_SEARCHES, {canBeMissing: true}); const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false, canBeMissing: true}); - + const personalDetails = usePersonalDetails(); + const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); + const [workspaceCardFeeds = getEmptyObject>()] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, {canBeMissing: true}); + const [userCardList] = useOnyx(ONYXKEYS.CARD_LIST, {canBeMissing: true}); + const allCards = useMemo(() => mergeCardListWithWorkspaceFeeds(workspaceCardFeeds ?? CONST.EMPTY_OBJECT, userCardList), [userCardList, workspaceCardFeeds]); + const [allFeeds = getEmptyObject>()] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {canBeMissing: true}); const {shouldUseNarrowLayout} = useResponsiveLayout(); const listRef = useRef(null); @@ -480,6 +489,10 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla onHighlightFirstItem={() => listRef.current?.updateAndScrollToFocusedIndex(1)} ref={listRef} textInputRef={textInputRef} + personalDetails={personalDetails} + reports={reports} + allFeeds={allFeeds} + allCards={allCards} /> )} diff --git a/src/components/SelectionList/ChatListItem.tsx b/src/components/SelectionList/ChatListItem.tsx index 8aab9575c783..e2a635e777c3 100644 --- a/src/components/SelectionList/ChatListItem.tsx +++ b/src/components/SelectionList/ChatListItem.tsx @@ -1,13 +1,11 @@ import React from 'react'; import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; -import useOnyx from '@hooks/useOnyx'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import {isInvoiceRoom, isPolicyExpenseChat} from '@libs/ReportUtils'; import ReportActionItem from '@pages/home/report/ReportActionItem'; import variables from '@styles/variables'; import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; import BaseListItem from './BaseListItem'; import type {ChatListItemProps, ListItem, ReportActionListItemType} from './types'; @@ -24,12 +22,9 @@ function ChatListItem({ shouldSyncFocus, policies, allReports, + report, }: ChatListItemProps) { const reportActionItem = item as unknown as ReportActionListItemType; - const reportID = Number(reportActionItem?.reportID ?? CONST.DEFAULT_NUMBER_ID); - const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, { - canBeMissing: true, - }); const styles = useThemeStyles(); const theme = useTheme(); const animatedHighlightStyle = useAnimatedHighlightStyle({ diff --git a/src/components/SelectionList/Search/TransactionGroupListItem.tsx b/src/components/SelectionList/Search/TransactionGroupListItem.tsx index 4f2e896e4f19..a145fb614c92 100644 --- a/src/components/SelectionList/Search/TransactionGroupListItem.tsx +++ b/src/components/SelectionList/Search/TransactionGroupListItem.tsx @@ -1,6 +1,5 @@ import React, {useMemo} from 'react'; import {View} from 'react-native'; -import type {OnyxCollection} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import type {SearchGroupBy} from '@components/Search/types'; import BaseListItem from '@components/SelectionList/BaseListItem'; @@ -17,7 +16,6 @@ import Text from '@components/Text'; import TransactionItemRow from '@components/TransactionItemRow'; import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; import useLocalize from '@hooks/useLocalize'; -import useOnyx from '@hooks/useOnyx'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -28,8 +26,6 @@ import {setActiveTransactionThreadIDs} from '@userActions/TransactionThreadNavig import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type {Policy} from '@src/types/onyx'; -import {getEmptyObject} from '@src/types/utils/EmptyObject'; import CardListItemHeader from './CardListItemHeader'; import MemberListItemHeader from './MemberListItemHeader'; import ReportListItemHeader from './ReportListItemHeader'; @@ -46,12 +42,12 @@ function TransactionGroupListItem({ onLongPressRow, shouldSyncFocus, groupBy, + policies, }: TransactionGroupListItemProps) { const groupItem = item as unknown as TransactionGroupListItemType; const theme = useTheme(); const styles = useThemeStyles(); const {translate} = useLocalize(); - const [policies = getEmptyObject>>()] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {allowStaleData: true, canBeMissing: true}); const policy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${groupItem?.policyID}`]; const isEmpty = groupItem.transactions.length === 0; const isDisabledOrEmpty = isEmpty || isDisabled; diff --git a/src/components/SelectionList/types.ts b/src/components/SelectionList/types.ts index c5bf7c2ef225..e50ee29327b4 100644 --- a/src/components/SelectionList/types.ts +++ b/src/components/SelectionList/types.ts @@ -463,6 +463,7 @@ type TaskListItemProps = ListItemProps & { type TransactionGroupListItemProps = ListItemProps & { groupBy?: SearchGroupBy; + policies?: OnyxCollection; }; type ChatListItemProps = ListItemProps & { @@ -473,6 +474,9 @@ type ChatListItemProps = ListItemProps & { /** All the data of the report collection */ allReports?: OnyxCollection; + + /** The report data */ + report?: Report; }; type ValidListItem = From 64d75dd8a455b3bcfe3b77bfee4f94b38d0b0431 Mon Sep 17 00:00:00 2001 From: Github Date: Wed, 9 Jul 2025 09:41:36 +0200 Subject: [PATCH 2/7] fix conflicts --- .../Search/SearchPageHeader/SearchPageHeaderInput.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx b/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx index 1bebf75ce3ad..ad7ff73d23fa 100644 --- a/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx +++ b/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx @@ -63,7 +63,7 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo const [userCardList] = useOnyx(ONYXKEYS.CARD_LIST, {canBeMissing: true}); const [workspaceCardFeeds = {}] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, {canBeMissing: true}); const allCards = useMemo(() => mergeCardListWithWorkspaceFeeds(workspaceCardFeeds ?? CONST.EMPTY_OBJECT, userCardList), [userCardList, workspaceCardFeeds]); - const [allFeeds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {canBeMissing: true}); + const [allFeeds = {}] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {canBeMissing: true}); const {inputQuery: originalInputQuery} = queryJSON; const isDefaultQuery = isDefaultExpensesQuery(queryJSON); const [shouldUseAnimation, setShouldUseAnimation] = useState(false); @@ -389,8 +389,8 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo ref={listRef} personalDetails={personalDetails} reports={reports} - workspaceCardFeeds={workspaceCardFeeds} allCards={allCards} + allFeeds={allFeeds} /> )} @@ -460,8 +460,8 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo shouldSubscribeToArrowKeyEvents={isAutocompleteListVisible} personalDetails={personalDetails} reports={reports} - workspaceCardFeeds={workspaceCardFeeds} allCards={allCards} + allFeeds={allFeeds} /> From 27fa473a4d5b5963b39a844bcbd27f8f71919111 Mon Sep 17 00:00:00 2001 From: Github Date: Wed, 9 Jul 2025 16:27:40 +0200 Subject: [PATCH 3/7] fix conflicts part 2 --- src/components/Search/SearchPageHeader/SearchPageHeader.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/Search/SearchPageHeader/SearchPageHeader.tsx b/src/components/Search/SearchPageHeader/SearchPageHeader.tsx index 2e5e36f39eff..f14f52478edc 100644 --- a/src/components/Search/SearchPageHeader/SearchPageHeader.tsx +++ b/src/components/Search/SearchPageHeader/SearchPageHeader.tsx @@ -6,10 +6,6 @@ import type {SearchQueryJSON} from '@components/Search/types'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import SearchSelectedNarrow from '@pages/Search/SearchSelectedNarrow'; import type CONST from '@src/CONST'; -<<<<<<< HEAD -======= -import type MobileSelectionMode from '@src/types/onyx/MobileSelectionMode'; ->>>>>>> 27fc4644c51 (perf: Move remaining useOnyx calls up in the Search component tree) import type DeepValueOf from '@src/types/utils/DeepValueOf'; import SearchPageHeaderInput from './SearchPageHeaderInput'; From 2d83b005028e76dc2bedd4d71940eec7646790c7 Mon Sep 17 00:00:00 2001 From: Github Date: Thu, 10 Jul 2025 13:03:01 +0200 Subject: [PATCH 4/7] fix conflicts part 3 --- Mobile-Expensify | 2 +- src/components/Search/SearchAutocompleteList.tsx | 10 +++++----- .../Search/SearchPageHeader/SearchPageHeaderInput.tsx | 6 ++++-- src/components/Search/SearchRouter/SearchRouter.tsx | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 3c9610642586..32922dcca0de 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 3c9610642586a19c6e12ef1fcadce8015ecb3481 +Subproject commit 32922dcca0de2dae6060cfccb1a3a40f1397c68b diff --git a/src/components/Search/SearchAutocompleteList.tsx b/src/components/Search/SearchAutocompleteList.tsx index d423c1d1edce..ee1fb9b5af94 100644 --- a/src/components/Search/SearchAutocompleteList.tsx +++ b/src/components/Search/SearchAutocompleteList.tsx @@ -39,7 +39,7 @@ import StringUtils from '@libs/StringUtils'; import Timing from '@userActions/Timing'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type * as OnyxTypes from '@src/types/onyx'; +import type {CardFeeds, CardList, PersonalDetailsList, Policy, Report} from '@src/types/onyx'; import type PersonalDetails from '@src/types/onyx/PersonalDetails'; import {getEmptyObject} from '@src/types/utils/EmptyObject'; import {getSubstitutionMapKey} from './SearchRouter/getQueryWithSubstitutions'; @@ -86,16 +86,16 @@ type SearchAutocompleteListProps = { textInputRef?: React.RefObject; /** Personal details */ - personalDetails: OnyxEntry; + personalDetails: OnyxEntry; /** Reports */ - reports: OnyxCollection; + reports: OnyxCollection; /** All feeds */ - allFeeds: Record; + allFeeds: Record; /** All cards */ - allCards: OnyxTypes.CardList; + allCards: CardList; }; const defaultListOptions = { diff --git a/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx b/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx index ad7ff73d23fa..8d323db67de2 100644 --- a/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx +++ b/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx @@ -37,6 +37,8 @@ import variables from '@styles/variables'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import type {CardFeeds, WorkspaceCardsList} from '@src/types/onyx'; +import {getEmptyObject} from '@src/types/utils/EmptyObject'; import KeyboardUtils from '@src/utils/keyboard'; import SearchTypeMenuPopover from './SearchTypeMenuPopover'; @@ -61,9 +63,9 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: false}); const taxRates = useMemo(() => getAllTaxRates(), []); const [userCardList] = useOnyx(ONYXKEYS.CARD_LIST, {canBeMissing: true}); - const [workspaceCardFeeds = {}] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, {canBeMissing: true}); + const [workspaceCardFeeds = getEmptyObject>()] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, {canBeMissing: true}); const allCards = useMemo(() => mergeCardListWithWorkspaceFeeds(workspaceCardFeeds ?? CONST.EMPTY_OBJECT, userCardList), [userCardList, workspaceCardFeeds]); - const [allFeeds = {}] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {canBeMissing: true}); + const [allFeeds = getEmptyObject>()] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {canBeMissing: true}); const {inputQuery: originalInputQuery} = queryJSON; const isDefaultQuery = isDefaultExpensesQuery(queryJSON); const [shouldUseAnimation, setShouldUseAnimation] = useState(false); diff --git a/src/components/Search/SearchRouter/SearchRouter.tsx b/src/components/Search/SearchRouter/SearchRouter.tsx index d2be157384e2..ebd7a921fba9 100644 --- a/src/components/Search/SearchRouter/SearchRouter.tsx +++ b/src/components/Search/SearchRouter/SearchRouter.tsx @@ -38,7 +38,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; -import {CardFeeds, WorkspaceCardsList} from '@src/types/onyx'; +import type {CardFeeds, WorkspaceCardsList} from '@src/types/onyx'; import type Report from '@src/types/onyx/Report'; import {getEmptyObject} from '@src/types/utils/EmptyObject'; import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; From 0b03b11a8700739e12170ed8b626cd7a1211f2d8 Mon Sep 17 00:00:00 2001 From: Github Date: Thu, 10 Jul 2025 16:17:01 +0200 Subject: [PATCH 5/7] change after CR --- src/components/Search/SearchList.tsx | 3 --- src/components/SelectionList/ChatListItem.tsx | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index 8e72a0993f8e..a7ecf385af49 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -275,8 +275,6 @@ function SearchList( const isItemFocused = focusedIndex === index; const isItemHighlighted = !!itemsToHighlight?.has(item.keyForList ?? ''); const isDisabled = item.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; - const reportID = Number(item?.reportID ?? CONST.DEFAULT_NUMBER_ID); - const report = allReports?.[reportID]; return ( ); }, diff --git a/src/components/SelectionList/ChatListItem.tsx b/src/components/SelectionList/ChatListItem.tsx index e2a635e777c3..f447dd222647 100644 --- a/src/components/SelectionList/ChatListItem.tsx +++ b/src/components/SelectionList/ChatListItem.tsx @@ -6,6 +6,7 @@ import {isInvoiceRoom, isPolicyExpenseChat} from '@libs/ReportUtils'; import ReportActionItem from '@pages/home/report/ReportActionItem'; import variables from '@styles/variables'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import BaseListItem from './BaseListItem'; import type {ChatListItemProps, ListItem, ReportActionListItemType} from './types'; @@ -22,9 +23,10 @@ function ChatListItem({ shouldSyncFocus, policies, allReports, - report, }: ChatListItemProps) { const reportActionItem = item as unknown as ReportActionListItemType; + const reportID = Number(reportActionItem?.reportID ?? CONST.DEFAULT_NUMBER_ID); + const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; const styles = useThemeStyles(); const theme = useTheme(); const animatedHighlightStyle = useAnimatedHighlightStyle({ From 5f6f8acc359351bfaa73eb7c151c5398967d649d Mon Sep 17 00:00:00 2001 From: Github Date: Fri, 11 Jul 2025 14:50:42 +0200 Subject: [PATCH 6/7] remove unnecessary getEmptyObject calls --- .../Search/SearchPageHeader/SearchPageHeaderInput.tsx | 10 ++++------ src/components/Search/SearchRouter/SearchRouter.tsx | 8 +++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx b/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx index 8d323db67de2..65fcccfd5cb0 100644 --- a/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx +++ b/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx @@ -37,8 +37,6 @@ import variables from '@styles/variables'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type {CardFeeds, WorkspaceCardsList} from '@src/types/onyx'; -import {getEmptyObject} from '@src/types/utils/EmptyObject'; import KeyboardUtils from '@src/utils/keyboard'; import SearchTypeMenuPopover from './SearchTypeMenuPopover'; @@ -63,9 +61,9 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: false}); const taxRates = useMemo(() => getAllTaxRates(), []); const [userCardList] = useOnyx(ONYXKEYS.CARD_LIST, {canBeMissing: true}); - const [workspaceCardFeeds = getEmptyObject>()] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, {canBeMissing: true}); + const [workspaceCardFeeds] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, {canBeMissing: true}); const allCards = useMemo(() => mergeCardListWithWorkspaceFeeds(workspaceCardFeeds ?? CONST.EMPTY_OBJECT, userCardList), [userCardList, workspaceCardFeeds]); - const [allFeeds = getEmptyObject>()] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {canBeMissing: true}); + const [allFeeds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {canBeMissing: true}); const {inputQuery: originalInputQuery} = queryJSON; const isDefaultQuery = isDefaultExpensesQuery(queryJSON); const [shouldUseAnimation, setShouldUseAnimation] = useState(false); @@ -392,7 +390,7 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo personalDetails={personalDetails} reports={reports} allCards={allCards} - allFeeds={allFeeds} + allFeeds={allFeeds ?? {}} /> )} @@ -463,7 +461,7 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo personalDetails={personalDetails} reports={reports} allCards={allCards} - allFeeds={allFeeds} + allFeeds={allFeeds ?? {}} /> diff --git a/src/components/Search/SearchRouter/SearchRouter.tsx b/src/components/Search/SearchRouter/SearchRouter.tsx index ebd7a921fba9..c348bd913fbc 100644 --- a/src/components/Search/SearchRouter/SearchRouter.tsx +++ b/src/components/Search/SearchRouter/SearchRouter.tsx @@ -38,9 +38,7 @@ import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import SCREENS from '@src/SCREENS'; -import type {CardFeeds, WorkspaceCardsList} from '@src/types/onyx'; import type Report from '@src/types/onyx/Report'; -import {getEmptyObject} from '@src/types/utils/EmptyObject'; import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; import type {SubstitutionMap} from './getQueryWithSubstitutions'; import {getQueryWithSubstitutions} from './getQueryWithSubstitutions'; @@ -88,10 +86,10 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false, canBeMissing: true}); const personalDetails = usePersonalDetails(); const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, {canBeMissing: true}); - const [workspaceCardFeeds = getEmptyObject>()] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, {canBeMissing: true}); + const [workspaceCardFeeds] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, {canBeMissing: true}); const [userCardList] = useOnyx(ONYXKEYS.CARD_LIST, {canBeMissing: true}); const allCards = useMemo(() => mergeCardListWithWorkspaceFeeds(workspaceCardFeeds ?? CONST.EMPTY_OBJECT, userCardList), [userCardList, workspaceCardFeeds]); - const [allFeeds = getEmptyObject>()] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {canBeMissing: true}); + const [allFeeds] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER, {canBeMissing: true}); const {shouldUseNarrowLayout} = useResponsiveLayout(); const listRef = useRef(null); @@ -491,7 +489,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla textInputRef={textInputRef} personalDetails={personalDetails} reports={reports} - allFeeds={allFeeds} + allFeeds={allFeeds ?? {}} allCards={allCards} /> From 65f120bf95dd1066e1bad907cb5645ac1515861d Mon Sep 17 00:00:00 2001 From: Github Date: Fri, 11 Jul 2025 16:13:00 +0200 Subject: [PATCH 7/7] small fix --- src/components/Search/SearchAutocompleteList.tsx | 2 +- .../Search/SearchPageHeader/SearchPageHeaderInput.tsx | 4 ++-- src/components/Search/SearchRouter/SearchRouter.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Search/SearchAutocompleteList.tsx b/src/components/Search/SearchAutocompleteList.tsx index ee1fb9b5af94..91694a6a8cee 100644 --- a/src/components/Search/SearchAutocompleteList.tsx +++ b/src/components/Search/SearchAutocompleteList.tsx @@ -92,7 +92,7 @@ type SearchAutocompleteListProps = { reports: OnyxCollection; /** All feeds */ - allFeeds: Record; + allFeeds: Record | undefined; /** All cards */ allCards: CardList; diff --git a/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx b/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx index 65fcccfd5cb0..214b7d08b621 100644 --- a/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx +++ b/src/components/Search/SearchPageHeader/SearchPageHeaderInput.tsx @@ -390,7 +390,7 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo personalDetails={personalDetails} reports={reports} allCards={allCards} - allFeeds={allFeeds ?? {}} + allFeeds={allFeeds} /> )} @@ -461,7 +461,7 @@ function SearchPageHeaderInput({queryJSON, searchRouterListVisible, hideSearchRo personalDetails={personalDetails} reports={reports} allCards={allCards} - allFeeds={allFeeds ?? {}} + allFeeds={allFeeds} /> diff --git a/src/components/Search/SearchRouter/SearchRouter.tsx b/src/components/Search/SearchRouter/SearchRouter.tsx index c348bd913fbc..aaa0d0787c84 100644 --- a/src/components/Search/SearchRouter/SearchRouter.tsx +++ b/src/components/Search/SearchRouter/SearchRouter.tsx @@ -489,7 +489,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla textInputRef={textInputRef} personalDetails={personalDetails} reports={reports} - allFeeds={allFeeds ?? {}} + allFeeds={allFeeds} allCards={allCards} />