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
14 changes: 14 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 All @@ -52,12 +54,16 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
const [transactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: false});
const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT, {canBeMissing: false});
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: false});
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID, {canBeMissing: true});
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {canBeMissing: true});
const [dismissedProductTraining, dismissedProductTrainingMetadata] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {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 @@ -233,6 +239,10 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
transactionViolations={transactionViolations}
onLayout={onLayoutItem}
shouldShowRBRorGBRTooltip={shouldShowRBRorGBRTooltip}
activePolicyID={activePolicyID}
onboardingPurpose={introSelected?.choice}
isFullscreenVisible={isFullscreenVisible}
isReportsSplitNavigatorLast={isReportsSplitNavigatorLast}
/>
);
},
Expand All @@ -253,6 +263,10 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
onLayoutItem,
isOffline,
firstReportIDWithGBRorRBR,
activePolicyID,
introSelected?.choice,
isFullscreenVisible,
isReportsSplitNavigatorLast,
],
);

Expand Down
19 changes: 7 additions & 12 deletions src/components/LHNOptionsList/OptionRowLHN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {useFocusEffect} from '@react-navigation/native';
import React, {useCallback, 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 @@ -19,7 +18,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 @@ -44,17 +42,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,
isFocused = false,
report,
onSelectRow = () => {},
optionItem,
viewMode = 'default',
activePolicyID,
onboardingPurpose,
isFullscreenVisible,
isReportsSplitNavigatorLast,
style,
onLayout = () => {},
hasDraftComment,
Expand All @@ -67,18 +68,12 @@ function OptionRowLHN({
const [isScreenFocused, setIsScreenFocused] = useState(false);
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}
isFocused={isReportFocused}
optionItem={optionItem}
report={fullReport}
/>
);
}
Expand Down
29 changes: 27 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 @@ -81,6 +81,17 @@ type OptionRowLHNDataProps = {
/** Array of report actions for this report */
reportActions: OnyxEntry<ReportActions>;

/** The active policy ID */
activePolicyID?: string;

/** The onboarding purpose */
onboardingPurpose?: OnboardingPurpose;

/** Whether the fullscreen is visible */
isFullscreenVisible?: boolean;

isReportsSplitNavigatorLast: boolean;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing comment


/**
* Array of report actions for the IOU report related to the last action of this report.
* If the last action is a report action preview, the last message of the report depends on
Expand Down Expand Up @@ -115,6 +126,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 */
isFocused?: boolean;

Expand All @@ -130,6 +144,17 @@ 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;

isReportsSplitNavigatorLast: boolean;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing comment


/** Whether a report contains a draft */
hasDraftComment: boolean;

Expand Down