diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index b6abe464bedb..fe215d0b4e40 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -15,6 +15,7 @@ import useLHNEstimatedListSize from '@hooks/useLHNEstimatedListSize'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; import usePrevious from '@hooks/usePrevious'; +import useRootNavigationState from '@hooks/useRootNavigationState'; import useScrollEventEmitter from '@hooks/useScrollEventEmitter'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -27,6 +28,7 @@ import {canUserPerformWriteAction} from '@libs/ReportUtils'; import isProductTrainingElementDismissed from '@libs/TooltipUtils'; import variables from '@styles/variables'; import CONST from '@src/CONST'; +import NAVIGATORS from '@src/NAVIGATORS'; import ONYXKEYS from '@src/ONYXKEYS'; import type {PersonalDetails, Report} from '@src/types/onyx'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; @@ -54,11 +56,15 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: false}); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: false}); const [dismissedProductTraining, dismissedProductTrainingMetadata] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {canBeMissing: true}); + const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); + const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); + const [isFullscreenVisible] = useOnyx(ONYXKEYS.FULLSCREEN_VISIBILITY, {canBeMissing: true}); const theme = useTheme(); const styles = useThemeStyles(); const {translate, preferredLocale} = useLocalize(); const estimatedListSize = useLHNEstimatedListSize(); + const isReportsSplitNavigatorLast = useRootNavigationState((state) => state?.routes?.at(-1)?.name === NAVIGATORS.REPORTS_SPLIT_NAVIGATOR); const shouldShowEmptyLHN = data.length === 0; const estimatedItemSize = optionMode === CONST.OPTION_MODE.COMPACT ? variables.optionRowHeightCompact : variables.optionRowHeight; const platform = getPlatform(); @@ -234,6 +240,10 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio transactionViolations={transactionViolations} onLayout={onLayoutItem} shouldShowRBRorGBRTooltip={shouldShowRBRorGBRTooltip} + activePolicyID={activePolicyID} + onboardingPurpose={introSelected?.choice} + isFullscreenVisible={isFullscreenVisible} + isReportsSplitNavigatorLast={isReportsSplitNavigatorLast} isScreenFocused={isScreenFocused} /> ); @@ -255,6 +265,10 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio onLayoutItem, isOffline, firstReportIDWithGBRorRBR, + activePolicyID, + introSelected?.choice, + isFullscreenVisible, + isReportsSplitNavigatorLast, isScreenFocused, ], ); @@ -275,6 +289,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio transactions, isOffline, isScreenFocused, + isReportsSplitNavigatorLast, ], [ reportActions, @@ -291,6 +306,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio transactions, isOffline, isScreenFocused, + isReportsSplitNavigatorLast, ], ); diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index f7038fb4475c..292799b920f2 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -1,7 +1,6 @@ import React, {useMemo, useRef, useState} from 'react'; import type {GestureResponderEvent, ViewStyle} from 'react-native'; import {StyleSheet, View} from 'react-native'; -import {useOnyx} from 'react-native-onyx'; import DisplayNames from '@components/DisplayNames'; import Hoverable from '@components/Hoverable'; import Icon from '@components/Icon'; @@ -18,7 +17,6 @@ import Tooltip from '@components/Tooltip'; import EducationalTooltip from '@components/Tooltip/EducationalTooltip'; import useLocalize from '@hooks/useLocalize'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; -import useRootNavigationState from '@hooks/useRootNavigationState'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -43,17 +41,20 @@ import FreeTrial from '@pages/settings/Subscription/FreeTrial'; import variables from '@styles/variables'; import Timing from '@userActions/Timing'; import CONST from '@src/CONST'; -import NAVIGATORS from '@src/NAVIGATORS'; -import ONYXKEYS from '@src/ONYXKEYS'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type {OptionRowLHNProps} from './types'; function OptionRowLHN({ reportID, + report, isOptionFocused = false, onSelectRow = () => {}, optionItem, viewMode = 'default', + activePolicyID, + onboardingPurpose, + isFullscreenVisible, + isReportsSplitNavigatorLast, style, onLayout = () => {}, hasDraftComment, @@ -66,18 +67,12 @@ function OptionRowLHN({ const StyleUtils = useStyleUtils(); const {shouldUseNarrowLayout} = useResponsiveLayout(); - const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${optionItem?.reportID}`, {canBeMissing: true}); - const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true}); - const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true}); - const [isFullscreenVisible] = useOnyx(ONYXKEYS.FULLSCREEN_VISIBILITY, {canBeMissing: true}); const session = useSession(); const shouldShowWorkspaceChatTooltip = isPolicyExpenseChat(report) && !isThread(report) && activePolicyID === report?.policyID && session?.accountID === report?.ownerAccountID; - const isOnboardingGuideAssigned = introSelected?.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !session?.email?.includes('+'); - const isChatUsedForOnboarding = isChatUsedForOnboardingReportUtils(report, introSelected?.choice); + const isOnboardingGuideAssigned = onboardingPurpose === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !session?.email?.includes('+'); + const isChatUsedForOnboarding = isChatUsedForOnboardingReportUtils(report, onboardingPurpose); const shouldShowGetStartedTooltip = isOnboardingGuideAssigned ? isAdminRoom(report) && isChatUsedForOnboarding : isConciergeChatReport(report); - const isReportsSplitNavigatorLast = useRootNavigationState((state) => state?.routes?.at(-1)?.name === NAVIGATORS.REPORTS_SPLIT_NAVIGATOR); - const {tooltipToRender, shouldShowTooltip, shouldTooltipBeLeftAligned} = useMemo(() => { let tooltip: ProductTrainingTooltipName; if (shouldShowRBRorGBRTooltip) { diff --git a/src/components/LHNOptionsList/OptionRowLHNData.tsx b/src/components/LHNOptionsList/OptionRowLHNData.tsx index 641c071112fc..41c3dbb45da8 100644 --- a/src/components/LHNOptionsList/OptionRowLHNData.tsx +++ b/src/components/LHNOptionsList/OptionRowLHNData.tsx @@ -90,6 +90,7 @@ function OptionRowLHNData({ {...propsToForward} isOptionFocused={isReportFocused} optionItem={optionItem} + report={fullReport} /> ); } diff --git a/src/components/LHNOptionsList/types.ts b/src/components/LHNOptionsList/types.ts index b290c0b55656..b56f0b6db90e 100644 --- a/src/components/LHNOptionsList/types.ts +++ b/src/components/LHNOptionsList/types.ts @@ -5,7 +5,7 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type {OptionData} from '@src/libs/ReportUtils'; -import type {Locale, PersonalDetailsList, Policy, Report, ReportAction, ReportActions, ReportNameValuePairs, Transaction, TransactionViolation} from '@src/types/onyx'; +import type {Locale, OnboardingPurpose, PersonalDetailsList, Policy, Report, ReportAction, ReportActions, ReportNameValuePairs, Transaction, TransactionViolation} from '@src/types/onyx'; import type {ReportAttributes} from '@src/types/onyx/DerivedValues'; type OptionMode = ValueOf; @@ -17,7 +17,7 @@ type CustomLHNOptionsListProps = { /** Extra styles for the section list container */ contentContainerStyles?: StyleProp; - /** Sections for the section list */ + /** List of reports */ data: Report[]; /** Callback to fire when a row is selected */ @@ -45,6 +45,18 @@ type OptionRowLHNDataProps = { /** The preferred language for the app */ preferredLocale?: OnyxEntry; + /** The active policy ID */ + activePolicyID?: string; + + /** The onboarding purpose */ + onboardingPurpose?: OnboardingPurpose; + + /** Whether the fullscreen is visible */ + isFullscreenVisible?: boolean; + + /** Whether the reports split navigator is last */ + isReportsSplitNavigatorLast: boolean; + /** The full data of the report */ fullReport: OnyxEntry; @@ -118,6 +130,9 @@ type OptionRowLHNProps = { /** The ID of the report that the option is for */ reportID: string; + /** The report for this option */ + report?: Report; + /** Whether this option is currently in focus so we can modify its style */ isOptionFocused?: boolean; @@ -133,6 +148,18 @@ type OptionRowLHNProps = { /** The item that should be rendered */ optionItem?: OptionData; + /** The active policy ID */ + activePolicyID?: string; + + /** The onboarding purpose */ + onboardingPurpose?: OnboardingPurpose; + + /** Whether the fullscreen is visible */ + isFullscreenVisible?: boolean; + + /** Whether the reports split navigator is last */ + isReportsSplitNavigatorLast: boolean; + /** Whether a report contains a draft */ hasDraftComment: boolean;