From 2a42737b9b1c009dea4514fe87fc3a5b44c4fd16 Mon Sep 17 00:00:00 2001 From: lorretheboy Date: Tue, 21 Oct 2025 12:11:42 +0800 Subject: [PATCH 1/5] fix: hide scan test tooltip in offline --- src/components/ProductTrainingContext/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/ProductTrainingContext/index.tsx b/src/components/ProductTrainingContext/index.tsx index ed758429d9e76..81ec32b400621 100644 --- a/src/components/ProductTrainingContext/index.tsx +++ b/src/components/ProductTrainingContext/index.tsx @@ -8,11 +8,13 @@ import * as Expensicons from '@components/Icon/Expensicons'; import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; import RenderHTML from '@components/RenderHTML'; import useLocalize from '@hooks/useLocalize'; +import useNetwork from '@hooks/useNetwork'; import useOnyx from '@hooks/useOnyx'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useSidePanel from '@hooks/useSidePanel'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import getPlatform from '@libs/getPlatform'; import {hasCompletedGuidedSetupFlowSelector} from '@libs/onboardingSelectors'; import {getActiveAdminWorkspaces, getActiveEmployeeWorkspaces, getGroupPaidPoliciesWithExpenseChatEnabled} from '@libs/PolicyUtils'; import isProductTrainingElementDismissed from '@libs/TooltipUtils'; @@ -231,6 +233,7 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou const theme = useTheme(); const {shouldHideToolTip} = useSidePanel(); const {translate} = useLocalize(); + const {isOffline} = useNetwork(); if (!context) { throw new Error('useProductTourContext must be used within a ProductTourProvider'); @@ -249,8 +252,13 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou }, [tooltipName, registerTooltip, unregisterTooltip, shouldShow]); const shouldShowProductTrainingTooltip = useMemo(() => { + const platform = getPlatform(); + const isNonNativePlatform = platform === CONST.PLATFORM.WEB || platform === CONST.PLATFORM.DESKTOP || platform === CONST.PLATFORM.MOBILE_WEB; + if (isNonNativePlatform && isOffline && tooltipName === CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP) { + return false; + } return shouldShow && shouldRenderTooltip(tooltipName) && !shouldHideToolTip; - }, [shouldRenderTooltip, tooltipName, shouldShow, shouldHideToolTip]); + }, [shouldRenderTooltip, tooltipName, shouldShow, shouldHideToolTip, isOffline]); const hideTooltip = useCallback( (isDismissedUsingCloseButton = false) => { From cd8184470dde04b49170948da8ea08779c6fa17f Mon Sep 17 00:00:00 2001 From: lorretheboy Date: Wed, 22 Oct 2025 01:20:52 +0800 Subject: [PATCH 2/5] fix: refactoring code --- src/components/ProductTrainingContext/index.tsx | 8 +------- src/pages/iou/request/IOURequestStartPage.tsx | 11 ++++++++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/ProductTrainingContext/index.tsx b/src/components/ProductTrainingContext/index.tsx index 81ec32b400621..81833fefdb209 100644 --- a/src/components/ProductTrainingContext/index.tsx +++ b/src/components/ProductTrainingContext/index.tsx @@ -233,7 +233,6 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou const theme = useTheme(); const {shouldHideToolTip} = useSidePanel(); const {translate} = useLocalize(); - const {isOffline} = useNetwork(); if (!context) { throw new Error('useProductTourContext must be used within a ProductTourProvider'); @@ -252,13 +251,8 @@ const useProductTrainingContext = (tooltipName: ProductTrainingTooltipName, shou }, [tooltipName, registerTooltip, unregisterTooltip, shouldShow]); const shouldShowProductTrainingTooltip = useMemo(() => { - const platform = getPlatform(); - const isNonNativePlatform = platform === CONST.PLATFORM.WEB || platform === CONST.PLATFORM.DESKTOP || platform === CONST.PLATFORM.MOBILE_WEB; - if (isNonNativePlatform && isOffline && tooltipName === CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP) { - return false; - } return shouldShow && shouldRenderTooltip(tooltipName) && !shouldHideToolTip; - }, [shouldRenderTooltip, tooltipName, shouldShow, shouldHideToolTip, isOffline]); + }, [shouldRenderTooltip, tooltipName, shouldShow, shouldHideToolTip]); const hideTooltip = useCallback( (isDismissedUsingCloseButton = false) => { diff --git a/src/pages/iou/request/IOURequestStartPage.tsx b/src/pages/iou/request/IOURequestStartPage.tsx index 69d61150bd869..0477db39e761f 100644 --- a/src/pages/iou/request/IOURequestStartPage.tsx +++ b/src/pages/iou/request/IOURequestStartPage.tsx @@ -11,6 +11,7 @@ import TabSelector from '@components/TabSelector/TabSelector'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useHandleBackButton from '@hooks/useHandleBackButton'; import useLocalize from '@hooks/useLocalize'; +import useNetwork from '@hooks/useNetwork'; import useOnyx from '@hooks/useOnyx'; import usePermissions from '@hooks/usePermissions'; import usePolicy from '@hooks/usePolicy'; @@ -20,8 +21,11 @@ import {dismissProductTraining} from '@libs/actions/Welcome'; import {isMobile} from '@libs/Browser'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; +import getPlatform from '@libs/getPlatform'; +import Platform from '@libs/getPlatform/types'; import Navigation from '@libs/Navigation/Navigation'; import OnyxTabNavigator, {TabScreenWithFocusTrapWrapper, TopTab} from '@libs/Navigation/OnyxTabNavigator'; +import {isOffline} from '@libs/Network/NetworkStore'; import {getIsUserSubmittedExpenseOrScannedReceipt} from '@libs/OptionsListUtils'; import Performance from '@libs/Performance'; import {getActivePoliciesWithExpenseChatAndPerDiemEnabled} from '@libs/PolicyUtils'; @@ -46,6 +50,9 @@ type IOURequestStartPageProps = WithWritableReportOrNotFoundProps 1); const [currentDate] = useOnyx(ONYXKEYS.CURRENT_DATE, {canBeMissing: true}); + const {isOffline} = useNetwork(); const tabTitles = { [CONST.IOU.TYPE.REQUEST]: translate('iou.createExpense'), @@ -184,7 +192,8 @@ function IOURequestStartPage({ const setTestReceiptAndNavigateRef = useRef<() => void>(() => {}); const {shouldShowProductTrainingTooltip, renderProductTrainingTooltip} = useProductTrainingContext( CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP, - !getIsUserSubmittedExpenseOrScannedReceipt() && isBetaEnabled(CONST.BETAS.NEWDOT_MANAGER_MCTEST) && selectedTab === CONST.TAB_REQUEST.SCAN, + // The test receipt image is served via our server on web so it requires internet connection + !getIsUserSubmittedExpenseOrScannedReceipt() && isBetaEnabled(CONST.BETAS.NEWDOT_MANAGER_MCTEST) && selectedTab === CONST.TAB_REQUEST.SCAN && !(isOffline && isWeb), { onConfirm: () => { setTestReceiptAndNavigateRef?.current?.(); From f151f9c2536fec38f0e2f7e1da6cec55ca875bb0 Mon Sep 17 00:00:00 2001 From: lorretheboy Date: Wed, 22 Oct 2025 01:21:27 +0800 Subject: [PATCH 3/5] fix: refactoring code --- src/components/ProductTrainingContext/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/ProductTrainingContext/index.tsx b/src/components/ProductTrainingContext/index.tsx index 81833fefdb209..ed758429d9e76 100644 --- a/src/components/ProductTrainingContext/index.tsx +++ b/src/components/ProductTrainingContext/index.tsx @@ -8,13 +8,11 @@ import * as Expensicons from '@components/Icon/Expensicons'; import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; import RenderHTML from '@components/RenderHTML'; import useLocalize from '@hooks/useLocalize'; -import useNetwork from '@hooks/useNetwork'; import useOnyx from '@hooks/useOnyx'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useSidePanel from '@hooks/useSidePanel'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import getPlatform from '@libs/getPlatform'; import {hasCompletedGuidedSetupFlowSelector} from '@libs/onboardingSelectors'; import {getActiveAdminWorkspaces, getActiveEmployeeWorkspaces, getGroupPaidPoliciesWithExpenseChatEnabled} from '@libs/PolicyUtils'; import isProductTrainingElementDismissed from '@libs/TooltipUtils'; From 1687dc876c708f229687556804feca0aa2ae62c2 Mon Sep 17 00:00:00 2001 From: lorretheboy Date: Wed, 22 Oct 2025 01:44:32 +0800 Subject: [PATCH 4/5] fix: lint --- src/pages/iou/request/IOURequestStartPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/iou/request/IOURequestStartPage.tsx b/src/pages/iou/request/IOURequestStartPage.tsx index 0477db39e761f..76bbd67632d9c 100644 --- a/src/pages/iou/request/IOURequestStartPage.tsx +++ b/src/pages/iou/request/IOURequestStartPage.tsx @@ -25,7 +25,6 @@ import getPlatform from '@libs/getPlatform'; import Platform from '@libs/getPlatform/types'; import Navigation from '@libs/Navigation/Navigation'; import OnyxTabNavigator, {TabScreenWithFocusTrapWrapper, TopTab} from '@libs/Navigation/OnyxTabNavigator'; -import {isOffline} from '@libs/Network/NetworkStore'; import {getIsUserSubmittedExpenseOrScannedReceipt} from '@libs/OptionsListUtils'; import Performance from '@libs/Performance'; import {getActivePoliciesWithExpenseChatAndPerDiemEnabled} from '@libs/PolicyUtils'; From 6b57da61c8d23b0cdf9e446a39349a45ba14d745 Mon Sep 17 00:00:00 2001 From: lorretheboy Date: Wed, 22 Oct 2025 02:08:11 +0800 Subject: [PATCH 5/5] fix: type --- src/pages/iou/request/IOURequestStartPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/IOURequestStartPage.tsx b/src/pages/iou/request/IOURequestStartPage.tsx index 76bbd67632d9c..bdfee6a17637c 100644 --- a/src/pages/iou/request/IOURequestStartPage.tsx +++ b/src/pages/iou/request/IOURequestStartPage.tsx @@ -22,7 +22,7 @@ import {isMobile} from '@libs/Browser'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; import getPlatform from '@libs/getPlatform'; -import Platform from '@libs/getPlatform/types'; +import type Platform from '@libs/getPlatform/types'; import Navigation from '@libs/Navigation/Navigation'; import OnyxTabNavigator, {TabScreenWithFocusTrapWrapper, TopTab} from '@libs/Navigation/OnyxTabNavigator'; import {getIsUserSubmittedExpenseOrScannedReceipt} from '@libs/OptionsListUtils';