From 36a5abff9da9e591282d4531a76b5c8287f37d2f Mon Sep 17 00:00:00 2001 From: bartlomiej obudzinski Date: Mon, 30 Mar 2026 12:58:43 +0200 Subject: [PATCH] perf: remove redundant reportNameValuePairs collection subscription from LHN --- src/components/LHNOptionsList/LHNOptionsList.tsx | 11 +++-------- src/components/LHNOptionsList/OptionRowLHNData.tsx | 11 +++++------ src/components/LHNOptionsList/types.ts | 5 +---- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index c359ab10f1bb2..eacfc4eb1c392 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -46,7 +46,6 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); const reportAttributes = useReportAttributes(); - const [reportNameValuePairs] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS); const [policy] = useOnyx(ONYXKEYS.COLLECTION.POLICY); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); @@ -154,7 +153,6 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio ({item, index}: RenderItemProps): ReactElement => { const reportID = item.reportID; const itemParentReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${item.parentReportID}`]; - const itemReportNameValuePairs = reportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`]; let invoiceReceiverPolicyID = '-1'; if (item?.invoiceReceiver && 'policyID' in item.invoiceReceiver) { @@ -172,7 +170,6 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio [reports, reportNameValuePairs, policy, personalDetails, data.length, optionMode, isOffline, isScreenFocused, isReportsSplitNavigatorLast], - [reports, reportNameValuePairs, policy, personalDetails, data.length, optionMode, isOffline, isScreenFocused, isReportsSplitNavigatorLast], + () => [reports, policy, personalDetails, data.length, optionMode, isOffline, isScreenFocused, isReportsSplitNavigatorLast], + [reports, policy, personalDetails, data.length, optionMode, isOffline, isScreenFocused, isReportsSplitNavigatorLast], ); const previousOptionMode = usePrevious(optionMode); @@ -273,11 +269,10 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio reportsCount: Object.keys(reports ?? {}).length, policyCount: Object.keys(policy ?? {}).length, personalDetailsCount: Object.keys(personalDetails ?? {}).length, - route, reportsIDsFromUseReportsCount: data.length, }); } - }, [data.length, shouldShowEmptyLHN, route, reports, policy, personalDetails]); + }, [data.length, shouldShowEmptyLHN, reports, policy, personalDetails]); return ( diff --git a/src/components/LHNOptionsList/OptionRowLHNData.tsx b/src/components/LHNOptionsList/OptionRowLHNData.tsx index fa0c33618a99f..653028a608224 100644 --- a/src/components/LHNOptionsList/OptionRowLHNData.tsx +++ b/src/components/LHNOptionsList/OptionRowLHNData.tsx @@ -28,7 +28,6 @@ import type {OptionRowLHNDataProps} from './types'; function OptionRowLHNData({ isOptionFocused = false, fullReport, - reportNameValuePairs, personalDetails = {}, policy, invoiceReceiverPolicy, @@ -89,7 +88,7 @@ function OptionRowLHNData({ const transactionID = isMoneyRequestAction(parentReportAction) ? (getOriginalMessage(parentReportAction)?.IOUTransactionID ?? CONST.DEFAULT_NUMBER_ID) : CONST.DEFAULT_NUMBER_ID; const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(transactionID !== CONST.DEFAULT_NUMBER_ID ? String(transactionID) : undefined)}`); - const isReportArchived = !!(reportNameValuePairsEntry ?? reportNameValuePairs)?.private_isArchived; + const isReportArchived = !!reportNameValuePairsEntry?.private_isArchived; const canUserPerformWrite = canUserPerformWriteActionUtil(fullReport, isReportArchived); const lastAction = useMemo(() => { @@ -103,8 +102,8 @@ function OptionRowLHNData({ }, [reportID, canUserPerformWrite, reportActions, transactionThreadReportActions, visibleReportActionsData, oneTransactionThreadReportID]); const iouReportIDOfLastAction = useMemo( - () => getIOUReportIDOfLastAction(fullReport, (reportNameValuePairsEntry ?? reportNameValuePairs)?.private_isArchived, visibleReportActionsData, lastAction), - [fullReport, reportNameValuePairsEntry, reportNameValuePairs, visibleReportActionsData, lastAction], + () => getIOUReportIDOfLastAction(fullReport, reportNameValuePairsEntry?.private_isArchived, visibleReportActionsData, lastAction), + [fullReport, reportNameValuePairsEntry?.private_isArchived, visibleReportActionsData, lastAction], ); const [iouReportReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getNonEmptyStringOnyxID(iouReportIDOfLastAction)}`); @@ -161,7 +160,7 @@ function OptionRowLHNData({ report: fullReport, reportAttributes, oneTransactionThreadReport, - reportNameValuePairs, + reportNameValuePairs: reportNameValuePairsEntry, personalDetails, policy, parentReportAction, @@ -188,7 +187,7 @@ function OptionRowLHNData({ fullReport, reportAttributes, oneTransactionThreadReport, - reportNameValuePairs, + reportNameValuePairsEntry, personalDetails, policy, parentReportAction, diff --git a/src/components/LHNOptionsList/types.ts b/src/components/LHNOptionsList/types.ts index eeafd63ccd5e2..8bd94f9d25cb6 100644 --- a/src/components/LHNOptionsList/types.ts +++ b/src/components/LHNOptionsList/types.ts @@ -5,7 +5,7 @@ import type {ValueOf} from 'type-fest'; import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleContextProvider'; import type CONST from '@src/CONST'; import type {OptionData} from '@src/libs/ReportUtils'; -import type {Onboarding, OnboardingPurpose, PersonalDetailsList, Policy, Report, ReportNameValuePairs} from '@src/types/onyx'; +import type {Onboarding, OnboardingPurpose, PersonalDetailsList, Policy, Report} from '@src/types/onyx'; type OptionMode = ValueOf; @@ -56,9 +56,6 @@ type OptionRowLHNDataProps = { /** The full data of the report */ fullReport: OnyxEntry; - /** Array of report name value pairs for this report */ - reportNameValuePairs: OnyxEntry; - /** The policy which the user has access to and which the report could be tied to */ policy?: OnyxEntry;