Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/components/LHNOptionsList/LHNOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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}
/>
);
Expand All @@ -255,6 +265,10 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
onLayoutItem,
isOffline,
firstReportIDWithGBRorRBR,
activePolicyID,
introSelected?.choice,
isFullscreenVisible,
isReportsSplitNavigatorLast,
isScreenFocused,
],
);
Expand All @@ -275,6 +289,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
transactions,
isOffline,
isScreenFocused,
isReportsSplitNavigatorLast,
],
[
reportActions,
Expand All @@ -291,6 +306,7 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
transactions,
isOffline,
isScreenFocused,
isReportsSplitNavigatorLast,
],
);

Expand Down
19 changes: 7 additions & 12 deletions src/components/LHNOptionsList/OptionRowLHN.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand All @@ -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,
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/components/LHNOptionsList/OptionRowLHNData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function OptionRowLHNData({
{...propsToForward}
isOptionFocused={isReportFocused}
optionItem={optionItem}
report={fullReport}
/>
);
}
Expand Down
31 changes: 29 additions & 2 deletions src/components/LHNOptionsList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof CONST.OPTION_MODE>;
Expand All @@ -17,7 +17,7 @@ type CustomLHNOptionsListProps = {
/** Extra styles for the section list container */
contentContainerStyles?: StyleProp<ContentStyle>;

/** Sections for the section list */
/** List of reports */
data: Report[];

/** Callback to fire when a row is selected */
Expand Down Expand Up @@ -45,6 +45,18 @@ type OptionRowLHNDataProps = {
/** The preferred language for the app */
preferredLocale?: OnyxEntry<Locale>;

/** 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<Report>;

Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand Down