From 254bd0ef3b60bb7b1745577899cadcd7003e7ef2 Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 11 Dec 2024 12:14:51 +0530 Subject: [PATCH 01/11] move free trial banner to admins room --- src/components/LHNOptionsList/OptionRowLHN.tsx | 5 ++++- src/libs/ReportUtils.ts | 14 +++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index c423d3101d92..7dcd4a22d7dc 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -60,6 +60,9 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const shouldShowToooltipOnThisReport = isOnboardingGuideAssigned ? ReportUtils.isAdminRoom(report) : ReportUtils.isConciergeChatReport(report); const [shouldHideGBRTooltip] = useOnyx(ONYXKEYS.NVP_SHOULD_HIDE_GBR_TOOLTIP, {initialValue: true}); + // During the onboarding flow, the introSelected NVP is not yet available. + const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED); + const {translate} = useLocalize(); const [isContextMenuActive, setIsContextMenuActive] = useState(false); @@ -284,7 +287,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti ReportUtils.isSystemChat(report) } /> - {ReportUtils.isChatUsedForOnboarding(report) && } + {ReportUtils.isChatUsedForOnboarding(report, onboardingPurposeSelected) && } {isStatusVisible && ( | OptionData): boolean { +function isChatUsedForOnboarding(optionOrReport: OnyxEntry | OptionData, onboardingPurposeSelected? : OnboardingPurpose ): boolean { // onboarding can be an array or an empty object for old accounts and accounts created from olddot if (onboarding && !Array.isArray(onboarding) && !isEmptyObject(onboarding) && onboarding.chatReportID) { return onboarding.chatReportID === optionOrReport?.reportID; } - - return (optionOrReport as OptionData)?.isConciergeChat ?? isConciergeChatReport(optionOrReport); + if (onboarding && (Array.isArray(onboarding) || isEmptyObject(onboarding))) { + return (optionOrReport as OptionData)?.isConciergeChat ?? isConciergeChatReport(optionOrReport); + } + // For users with emails that do not contain a ‘+’, and who select the MANAGE_TEAM intent, the onboarding tasks are in the #admins room. + return onboardingPurposeSelected === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !currentUserEmail?.includes('+') ? isAdminRoom(optionOrReport) : (optionOrReport as OptionData)?.isConciergeChat ?? isConciergeChatReport(optionOrReport); + } /** @@ -8325,7 +8329,7 @@ function isChatUsedForOnboarding(optionOrReport: OnyxEntry | OptionData) * we also used the system DM for A/B tests. */ function getChatUsedForOnboarding(): OnyxEntry { - return Object.values(ReportConnection.getAllReports() ?? {}).find(isChatUsedForOnboarding); + return Object.values(ReportConnection.getAllReports() ?? {}).find((report) => isChatUsedForOnboarding(report)); } /** From 640d83b04b587ac3be7e00552041f419a4b938fb Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 11 Dec 2024 13:33:54 +0530 Subject: [PATCH 02/11] free trial logic for header for manage team intent --- src/components/LHNOptionsList/OptionRowLHN.tsx | 6 ++++-- src/libs/ReportUtils.ts | 7 ++++--- src/pages/home/HeaderView.tsx | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 7dcd4a22d7dc..4cc173e27bfe 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -60,7 +60,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const shouldShowToooltipOnThisReport = isOnboardingGuideAssigned ? ReportUtils.isAdminRoom(report) : ReportUtils.isConciergeChatReport(report); const [shouldHideGBRTooltip] = useOnyx(ONYXKEYS.NVP_SHOULD_HIDE_GBR_TOOLTIP, {initialValue: true}); - // During the onboarding flow, the introSelected NVP is not yet available. + // During the onboarding flow, the introSelected NVP is not yet available. const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED); const {translate} = useLocalize(); @@ -287,7 +287,9 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti ReportUtils.isSystemChat(report) } /> - {ReportUtils.isChatUsedForOnboarding(report, onboardingPurposeSelected) && } + {ReportUtils.isChatUsedForOnboarding(report, onboardingPurposeSelected) && ( + + )} {isStatusVisible && ( | OptionData, onboardingPurposeSelected? : OnboardingPurpose ): boolean { +function isChatUsedForOnboarding(optionOrReport: OnyxEntry | OptionData, onboardingPurposeSelected?: OnboardingPurpose): boolean { // onboarding can be an array or an empty object for old accounts and accounts created from olddot if (onboarding && !Array.isArray(onboarding) && !isEmptyObject(onboarding) && onboarding.chatReportID) { return onboarding.chatReportID === optionOrReport?.reportID; @@ -8320,8 +8320,9 @@ function isChatUsedForOnboarding(optionOrReport: OnyxEntry | OptionData, return (optionOrReport as OptionData)?.isConciergeChat ?? isConciergeChatReport(optionOrReport); } // For users with emails that do not contain a ‘+’, and who select the MANAGE_TEAM intent, the onboarding tasks are in the #admins room. - return onboardingPurposeSelected === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !currentUserEmail?.includes('+') ? isAdminRoom(optionOrReport) : (optionOrReport as OptionData)?.isConciergeChat ?? isConciergeChatReport(optionOrReport); - + return onboardingPurposeSelected === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !currentUserEmail?.includes('+') + ? isAdminRoom(optionOrReport) + : (optionOrReport as OptionData)?.isConciergeChat ?? isConciergeChatReport(optionOrReport); } /** diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index d55b3ad04db4..781bb9c9e55c 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -151,7 +151,8 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto const isReportInRHP = route.name === SCREENS.SEARCH.REPORT_RHP; const shouldDisplaySearchRouter = !isReportInRHP || isSmallScreenWidth; - const isChatUsedForOnboarding = ReportUtils.isChatUsedForOnboarding(report); + const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED); + const isChatUsedForOnboarding = ReportUtils.isChatUsedForOnboarding(report, onboardingPurposeSelected); return ( Date: Mon, 16 Dec 2024 13:21:26 +0530 Subject: [PATCH 03/11] prettier --- src/components/LHNOptionsList/OptionRowLHN.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 6aef4f113788..d5879fe1d2e6 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -62,11 +62,10 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti }, [shouldShowGetStartedTooltip, isScreenFocused, shouldUseNarrowLayout]); const {shouldShowProductTrainingTooltip, renderProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext(tooltipToRender, shouldShowTooltip); - + // During the onboarding flow, the introSelected NVP is not yet available. const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED); - const {translate} = useLocalize(); const [isContextMenuActive, setIsContextMenuActive] = useState(false); From 51c14830e54d22353402b8899dc5493db8eccc9d Mon Sep 17 00:00:00 2001 From: c3024 Date: Wed, 18 Dec 2024 19:29:08 +0530 Subject: [PATCH 04/11] prettier --- src/components/LHNOptionsList/OptionRowLHN.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 550da3355e3b..4cc173e27bfe 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -60,7 +60,6 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const shouldShowToooltipOnThisReport = isOnboardingGuideAssigned ? ReportUtils.isAdminRoom(report) : ReportUtils.isConciergeChatReport(report); const [shouldHideGBRTooltip] = useOnyx(ONYXKEYS.NVP_SHOULD_HIDE_GBR_TOOLTIP, {initialValue: true}); - // During the onboarding flow, the introSelected NVP is not yet available. const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED); From 81563507b46103af50af287540213ed8191f154b Mon Sep 17 00:00:00 2001 From: c3024 Date: Thu, 19 Dec 2024 13:19:08 +0530 Subject: [PATCH 05/11] fix lint --- src/ROUTES.ts | 2 +- src/components/LHNOptionsList/OptionRowLHN.tsx | 2 +- src/libs/ReportUtils.ts | 2 +- src/pages/home/HeaderView.tsx | 10 ++++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index f48a5cae92f0..c3a8345b7afe 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -862,7 +862,7 @@ const ROUTES = { }, WORKSPACE_PROFILE_DESCRIPTION: { route: 'settings/workspaces/:policyID/profile/description', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile/description` as const, + getRoute: (policyID: string | undefined) => `settings/workspaces/${policyID}/profile/description` as const, }, WORKSPACE_PROFILE_SHARE: { route: 'settings/workspaces/:policyID/profile/share', diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 4cc173e27bfe..c9ce49854ac4 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -47,7 +47,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const {shouldUseNarrowLayout} = useResponsiveLayout(); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${optionItem?.reportID || -1}`); + const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${optionItem?.reportID || CONST.DEFAULT_NUMBER_ID}`); const [isFirstTimeNewExpensifyUser] = useOnyx(ONYXKEYS.NVP_IS_FIRST_TIME_NEW_EXPENSIFY_USER); const [isOnboardingCompleted = true] = useOnyx(ONYXKEYS.NVP_ONBOARDING, { selector: hasCompletedGuidedSetupFlowSelector, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f18a944f607c..57a50d604d9d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1040,7 +1040,7 @@ function isSettled(reportOrID: OnyxInputOrEntry | SearchReport | string /** * Whether the current user is the submitter of the report */ -function isCurrentUserSubmitter(reportID: string): boolean { +function isCurrentUserSubmitter(reportID: string | undefined): boolean { if (!allReports) { return false; } diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index 8c28c9e3aa82..302c160d50cc 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -70,9 +70,11 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto const {isSmallScreenWidth} = useResponsiveLayout(); const route = useRoute(); const [isDeleteTaskConfirmModalVisible, setIsDeleteTaskConfirmModalVisible] = React.useState(false); - const [invoiceReceiverPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.invoiceReceiver && 'policyID' in report.invoiceReceiver ? report.invoiceReceiver.policyID : -1}`); + const [invoiceReceiverPolicy] = useOnyx( + `${ONYXKEYS.COLLECTION.POLICY}${report?.invoiceReceiver && 'policyID' in report.invoiceReceiver ? report.invoiceReceiver.policyID : CONST.DEFAULT_NUMBER_ID}`, + ); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID || report?.reportID || '-1'}`); + const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID || report?.reportID}`); const policy = usePolicy(report?.policyID); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); @@ -100,7 +102,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto const reportDescription = Parser.htmlToText(ReportUtils.getReportDescription(report)); const policyName = ReportUtils.getPolicyName(report, true); const policyDescription = ReportUtils.getPolicyDescriptionText(policy); - const isPersonalExpenseChat = isPolicyExpenseChat && ReportUtils.isCurrentUserSubmitter(report?.reportID ?? ''); + const isPersonalExpenseChat = isPolicyExpenseChat && ReportUtils.isCurrentUserSubmitter(report?.reportID); const shouldShowSubtitle = () => { if (!subtitle) { return false; @@ -261,7 +263,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto { if (ReportUtils.canEditPolicyDescription(policy)) { - Navigation.navigate(ROUTES.WORKSPACE_PROFILE_DESCRIPTION.getRoute(report.policyID ?? '-1')); + Navigation.navigate(ROUTES.WORKSPACE_PROFILE_DESCRIPTION.getRoute(report.policyID)); return; } Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(reportID, Navigation.getReportRHPActiveRoute())); From cf4dc60e7115eb9bae7072c8bab09d062a488d38 Mon Sep 17 00:00:00 2001 From: c3024 Date: Thu, 19 Dec 2024 20:31:27 +0530 Subject: [PATCH 06/11] fix potential errors due to lint changes --- src/libs/ReportUtils.ts | 2 +- src/pages/home/HeaderView.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 09c0622b1a23..50defba51843 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1041,7 +1041,7 @@ function isSettled(reportOrID: OnyxInputOrEntry | SearchReport | string * Whether the current user is the submitter of the report */ function isCurrentUserSubmitter(reportID: string | undefined): boolean { - if (!allReports) { + if (!allReports || !reportID) { return false; } const report = allReports[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index 302c160d50cc..7443329ebbb4 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -74,7 +74,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto `${ONYXKEYS.COLLECTION.POLICY}${report?.invoiceReceiver && 'policyID' in report.invoiceReceiver ? report.invoiceReceiver.policyID : CONST.DEFAULT_NUMBER_ID}`, ); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID || report?.reportID}`); + const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID || report?.reportID || undefined}`); const policy = usePolicy(report?.policyID); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); From b437baf1e4454d943968d147208a9fa99b2aebb1 Mon Sep 17 00:00:00 2001 From: c3024 Date: Thu, 9 Jan 2025 23:43:34 +0530 Subject: [PATCH 07/11] remove redundant comment --- src/libs/ReportUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 83b71687705f..9f9bde8253a9 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -8454,7 +8454,6 @@ function isChatUsedForOnboarding(optionOrReport: OnyxEntry | OptionData, if (isEmptyObject(onboarding)) { return (optionOrReport as OptionData)?.isConciergeChat ?? isConciergeChatReport(optionOrReport); } - // For users with emails that do not contain a ‘+’, and who select the MANAGE_TEAM intent, the onboarding tasks are in the #admins room. return onboardingPurposeSelected === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !currentUserEmail?.includes('+') ? isAdminRoom(optionOrReport) : (optionOrReport as OptionData)?.isConciergeChat ?? isConciergeChatReport(optionOrReport); From 8afaca3c1f48b5b26e109d06fb257ead3e6f2355 Mon Sep 17 00:00:00 2001 From: c3024 Date: Tue, 14 Jan 2025 07:43:16 +0530 Subject: [PATCH 08/11] make the comment to explain the why --- src/libs/ReportUtils.ts | 3 +++ src/pages/home/ReportScreen.tsx | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 4858ccd5ecb5..f65a9e8512d6 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -8457,6 +8457,9 @@ function isChatUsedForOnboarding(optionOrReport: OnyxEntry | OptionData, if (isEmptyObject(onboarding)) { return (optionOrReport as OptionData)?.isConciergeChat ?? isConciergeChatReport(optionOrReport); } + + // Onboarding guides are assigned to signups with emails that do not contain a '+' and select the "Manage my team's expenses" intent. + // Guides and onboarding tasks are posted to the #admins room to facilitate the onboarding process. return onboardingPurposeSelected === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !currentUserEmail?.includes('+') ? isAdminRoom(optionOrReport) : (optionOrReport as OptionData)?.isConciergeChat ?? isConciergeChatReport(optionOrReport); diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index b02ccec1a56b..cec9962e8c77 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -72,6 +72,7 @@ const defaultReportMetadata = { function getReportID(route: ReportScreenNavigationProps['route']): string { // The report ID is used in an onyx key. If it's an empty string, onyx will return // a collection instead of an individual report. + console.log('getReportID', route.params?.reportID); return String(route.params?.reportID || 0); } @@ -189,7 +190,7 @@ function ReportScreen({route, navigation}: ReportScreenProps) { () => reportOnyx && { lastReadTime: reportOnyx.lastReadTime, - reportID: reportOnyx.reportID ?? '', + reportID: reportOnyx.reportID ?? CONST.DEFAULT_NUMBER_ID, policyID: reportOnyx.policyID, lastVisibleActionCreated: reportOnyx.lastVisibleActionCreated, statusNum: reportOnyx.statusNum, From 41716d5fbd6726fe634251495a9e6b6e7ef1b159 Mon Sep 17 00:00:00 2001 From: c3024 Date: Thu, 16 Jan 2025 08:13:42 +0530 Subject: [PATCH 09/11] use named reports to fix lint errors --- src/components/LHNOptionsList/OptionRowLHN.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 9aca347fb22c..00b406353f3a 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -24,7 +24,7 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import DateUtils from '@libs/DateUtils'; import DomUtils from '@libs/DomUtils'; -import * as OptionsListUtils from '@libs/OptionsListUtils'; +import {shouldOptionShowTooltip, shouldUseBoldText} from '@libs/OptionsListUtils'; import Parser from '@libs/Parser'; import Performance from '@libs/Performance'; import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager'; @@ -110,7 +110,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const hasBrickError = optionItem.brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; const shouldShowGreenDotIndicator = !hasBrickError && ReportUtils.requiresAttentionFromCurrentUser(optionItem, optionItem.parentReportAction); const textStyle = isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText; - const textUnreadStyle = OptionsListUtils.shouldUseBoldText(optionItem) ? [textStyle, styles.sidebarLinkTextBold] : [textStyle]; + const textUnreadStyle = shouldUseBoldText(optionItem) ? [textStyle, styles.sidebarLinkTextBold] : [textStyle]; const displayNameStyle = [styles.optionDisplayName, styles.optionDisplayNameCompact, styles.pre, textUnreadStyle, style]; const alternateTextStyle = isInFocusMode ? [textStyle, styles.textLabelSupporting, styles.optionAlternateTextCompact, styles.ml2, style] @@ -248,7 +248,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti isFocused ? StyleUtils.getBackgroundAndBorderStyle(focusedBackgroundColor) : undefined, hovered && !isFocused ? StyleUtils.getBackgroundAndBorderStyle(hoveredBackgroundColor) : undefined, ]} - shouldShowTooltip={OptionsListUtils.shouldOptionShowTooltip(optionItem)} + shouldShowTooltip={shouldOptionShowTooltip(optionItem)} /> ))} From 116cda619e2c1dc79fd6dea44d271b92ba7409ec Mon Sep 17 00:00:00 2001 From: c3024 Date: Thu, 16 Jan 2025 08:24:05 +0530 Subject: [PATCH 10/11] use named imports to fix lint errors --- .../LHNOptionsList/OptionRowLHN.tsx | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 00b406353f3a..0cd82bf695f5 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -28,7 +28,16 @@ import {shouldOptionShowTooltip, shouldUseBoldText} from '@libs/OptionsListUtils import Parser from '@libs/Parser'; import Performance from '@libs/Performance'; import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager'; -import * as ReportUtils from '@libs/ReportUtils'; +import { + isAdminRoom, + isChatUsedForOnboarding, + isConciergeChatReport, + isGroupChat, + isOneOnOneChat, + isPolicyExpenseChat, + isSystemChat, + requiresAttentionFromCurrentUser, +} from '@libs/ReportUtils'; import * as ReportActionContextMenu from '@pages/home/report/ContextMenu/ReportActionContextMenu'; import FreeTrial from '@pages/settings/Subscription/FreeTrial'; import variables from '@styles/variables'; @@ -51,9 +60,9 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); const session = useSession(); - const shouldShowWokspaceChatTooltip = ReportUtils.isPolicyExpenseChat(report) && activePolicyID === report?.policyID && session?.accountID === report?.ownerAccountID; + const shouldShowWokspaceChatTooltip = isPolicyExpenseChat(report) && activePolicyID === report?.policyID && session?.accountID === report?.ownerAccountID; const isOnboardingGuideAssigned = introSelected?.choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && !session?.email?.includes('+'); - const shouldShowGetStartedTooltip = isOnboardingGuideAssigned ? ReportUtils.isAdminRoom(report) : ReportUtils.isConciergeChatReport(report); + const shouldShowGetStartedTooltip = isOnboardingGuideAssigned ? isAdminRoom(report) : isConciergeChatReport(report); const isActiveRouteHome = useIsCurrentRouteHome(); const {tooltipToRender, shouldShowTooltip} = useMemo(() => { @@ -108,7 +117,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti } const hasBrickError = optionItem.brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR; - const shouldShowGreenDotIndicator = !hasBrickError && ReportUtils.requiresAttentionFromCurrentUser(optionItem, optionItem.parentReportAction); + const shouldShowGreenDotIndicator = !hasBrickError && requiresAttentionFromCurrentUser(optionItem, optionItem.parentReportAction); const textStyle = isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText; const textUnreadStyle = shouldUseBoldText(optionItem) ? [textStyle, styles.sidebarLinkTextBold] : [textStyle]; const displayNameStyle = [styles.optionDisplayName, styles.optionDisplayNameCompact, styles.pre, textUnreadStyle, style]; @@ -153,7 +162,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const statusClearAfterDate = optionItem.status?.clearAfter ?? ''; const formattedDate = DateUtils.getStatusUntilDate(statusClearAfterDate); const statusContent = formattedDate ? `${statusText ? `${statusText} ` : ''}(${formattedDate})` : statusText; - const isStatusVisible = !!emojiCode && ReportUtils.isOneOnOneChat(!isEmptyObject(report) ? report : undefined); + const isStatusVisible = !!emojiCode && isOneOnOneChat(!isEmptyObject(report) ? report : undefined); const subscriptAvatarBorderColor = isFocused ? focusedBackgroundColor : theme.sidebar; const firstIcon = optionItem.icons?.at(0); @@ -267,13 +276,11 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti !!optionItem.isThread || !!optionItem.isMoneyRequestReport || !!optionItem.isInvoiceReport || - ReportUtils.isGroupChat(report) || - ReportUtils.isSystemChat(report) + isGroupChat(report) || + isSystemChat(report) } /> - {ReportUtils.isChatUsedForOnboarding(report, onboardingPurposeSelected) && ( - - )} + {isChatUsedForOnboarding(report, onboardingPurposeSelected) && } {isStatusVisible && ( Date: Fri, 17 Jan 2025 03:37:44 +0530 Subject: [PATCH 11/11] remove fallback for string reportID --- src/components/LHNOptionsList/OptionRowLHN.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 0cd82bf695f5..2dc93aa8c9c1 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -56,7 +56,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const {shouldUseNarrowLayout} = useResponsiveLayout(); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${optionItem?.reportID || CONST.DEFAULT_NUMBER_ID}`); + const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${optionItem?.reportID}`); const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); const session = useSession();