From 55437c92ac981a79c8a49ea65153ace3976d73a9 Mon Sep 17 00:00:00 2001 From: paulnjs Date: Wed, 29 Oct 2025 19:07:56 +0700 Subject: [PATCH 1/2] fix: duplicate sound effect on test drive --- src/components/TestDrive/TestDriveDemo.tsx | 16 +++++++++++++- src/libs/actions/Tour.ts | 15 +------------ src/pages/Search/EmptySearchView.tsx | 11 +--------- .../FloatingActionButtonAndPopover.tsx | 22 +------------------ tests/actions/TourTest.ts | 21 +++++------------- 5 files changed, 24 insertions(+), 61 deletions(-) diff --git a/src/components/TestDrive/TestDriveDemo.tsx b/src/components/TestDrive/TestDriveDemo.tsx index 81daaf5881a1c..8cd4811e0eecf 100644 --- a/src/components/TestDrive/TestDriveDemo.tsx +++ b/src/components/TestDrive/TestDriveDemo.tsx @@ -12,6 +12,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import {completeTestDriveTask} from '@libs/actions/Task'; import Navigation from '@libs/Navigation/Navigation'; +import {hasSeenTourSelector} from '@libs/onboardingSelectors'; import {isPaidGroupPolicy, isPolicyAdmin} from '@libs/PolicyUtils'; import {isAdminRoom} from '@libs/ReportUtils'; import {getTestDriveURL} from '@libs/TourUtils'; @@ -39,11 +40,24 @@ function TestDriveDemo() { selector: (policies) => Object.values(policies ?? {}).some((policy) => isPaidGroupPolicy(policy) && isPolicyAdmin(policy, currentUserPersonalDetails.login)), }); + const [hasSeenTour = false] = useOnyx(ONYXKEYS.NVP_ONBOARDING, { + selector: hasSeenTourSelector, + canBeMissing: true, + }); + + useEffect(() => { + if (hasSeenTour) { + return; + } + InteractionManager.runAfterInteractions(() => { + completeTestDriveTask(viewTourTaskReport, viewTourTaskParentReport, isViewTourTaskParentReportArchived, currentUserPersonalDetails.accountID); + }); + }, [hasSeenTour]); + useEffect(() => { // eslint-disable-next-line @typescript-eslint/no-deprecated InteractionManager.runAfterInteractions(() => { setIsVisible(true); - completeTestDriveTask(viewTourTaskReport, viewTourTaskParentReport, isViewTourTaskParentReportArchived, currentUserPersonalDetails.accountID); }); // This should fire only during mount. diff --git a/src/libs/actions/Tour.ts b/src/libs/actions/Tour.ts index a19e566ca4811..c9be2457b27df 100644 --- a/src/libs/actions/Tour.ts +++ b/src/libs/actions/Tour.ts @@ -1,22 +1,10 @@ import {InteractionManager} from 'react-native'; -import type {OnyxEntry} from 'react-native-onyx'; import Navigation from '@libs/Navigation/Navigation'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; -import type * as OnyxTypes from '@src/types/onyx'; import type {IntroSelected} from './Report'; -import {completeTestDriveTask} from './Task'; -function startTestDrive( - introSelected: IntroSelected | undefined, - shouldUpdateSelfTourViewedOnlyLocally: boolean, - hasUserBeenAddedToNudgeMigration: boolean, - isUserPaidPolicyMember: boolean, - viewTourTaskReport: OnyxEntry, - viewTourTaskParentReport: OnyxEntry, - isViewTourTaskParentReportArchived: boolean, - currentUserAccountID: number, -) { +function startTestDrive(introSelected: IntroSelected | undefined, hasUserBeenAddedToNudgeMigration: boolean, isUserPaidPolicyMember: boolean) { // eslint-disable-next-line @typescript-eslint/no-deprecated InteractionManager.runAfterInteractions(() => { if ( @@ -27,7 +15,6 @@ function startTestDrive( introSelected?.choice === CONST.ONBOARDING_CHOICES.TRACK_WORKSPACE || (introSelected?.choice === CONST.ONBOARDING_CHOICES.SUBMIT && introSelected.inviteType === CONST.ONBOARDING_INVITE_TYPES.WORKSPACE) ) { - completeTestDriveTask(viewTourTaskReport, viewTourTaskParentReport, isViewTourTaskParentReportArchived, currentUserAccountID, shouldUpdateSelfTourViewedOnlyLocally); Navigation.navigate(ROUTES.TEST_DRIVE_DEMO_ROOT); } else { Navigation.navigate(ROUTES.TEST_DRIVE_MODAL_ROOT.route); diff --git a/src/pages/Search/EmptySearchView.tsx b/src/pages/Search/EmptySearchView.tsx index 1a3084cd99ed3..a4048b41d1b00 100644 --- a/src/pages/Search/EmptySearchView.tsx +++ b/src/pages/Search/EmptySearchView.tsx @@ -285,16 +285,7 @@ function EmptySearchViewContent({ } const startTestDriveAction = () => { - startTestDrive( - introSelected, - false, - tryNewDot?.hasBeenAddedToNudgeMigration ?? false, - isUserPaidPolicyMember, - viewTourTaskReport, - viewTourTaskParentReport, - isViewTourTaskParentReportArchived, - currentUserPersonalDetails.accountID, - ); + startTestDrive(introSelected, tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember); }; // If we didn't match a specific search hash, show a specific message based on the type of the data diff --git a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx index e401ded3842b1..f834d831b1125 100644 --- a/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/FloatingActionButtonAndPopover.tsx @@ -16,7 +16,6 @@ import PopoverMenu from '@components/PopoverMenu'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; -import useOnboardingTaskInformation from '@hooks/useOnboardingTaskInformation'; import useOnyx from '@hooks/useOnyx'; import usePermissions from '@hooks/usePermissions'; import usePreferredPolicy from '@hooks/usePreferredPolicy'; @@ -30,7 +29,6 @@ import {startDistanceRequest, startMoneyRequest} from '@libs/actions/IOU'; import {openOldDotLink} from '@libs/actions/Link'; import {navigateToQuickAction} from '@libs/actions/QuickActionNavigation'; import {createNewReport, startNewChat} from '@libs/actions/Report'; -import {isAnonymousUser} from '@libs/actions/Session'; import {startTestDrive} from '@libs/actions/Tour'; import getIconForAction from '@libs/getIconForAction'; import interceptAnonymousUser from '@libs/interceptAnonymousUser'; @@ -163,12 +161,6 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref }); const reportID = useMemo(() => generateReportID(), []); - const { - taskReport: viewTourTaskReport, - taskParentReport: viewTourTaskParentReport, - isOnboardingTaskParentReportArchived: isViewTourTaskParentReportArchived, - } = useOnboardingTaskInformation(CONST.ONBOARDING_TASK_TYPE.VIEW_TOUR); - const isReportInSearch = isOnSearchMoneyRequestReportPage(); const groupPoliciesWithChatEnabled = getGroupPaidPoliciesWithExpenseChatEnabled(); @@ -564,19 +556,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu, ref iconStyles: styles.popoverIconCircle, iconFill: theme.icon, text: translate('testDrive.quickAction.takeATwoMinuteTestDrive'), - onSelected: () => - interceptAnonymousUser(() => - startTestDrive( - introSelected, - isAnonymousUser(), - tryNewDot?.hasBeenAddedToNudgeMigration ?? false, - isUserPaidPolicyMember, - viewTourTaskReport, - viewTourTaskParentReport, - isViewTourTaskParentReportArchived, - currentUserPersonalDetails.accountID, - ), - ), + onSelected: () => interceptAnonymousUser(() => startTestDrive(introSelected, tryNewDot?.hasBeenAddedToNudgeMigration ?? false, isUserPaidPolicyMember)), }, ] : []), diff --git a/tests/actions/TourTest.ts b/tests/actions/TourTest.ts index 69b9d272bf3d0..8a30912889a34 100644 --- a/tests/actions/TourTest.ts +++ b/tests/actions/TourTest.ts @@ -38,14 +38,14 @@ describe('actions/Tour', () => { describe('startTestDrive', () => { describe('migrated users', () => { it('should show the Test Drive demo if user has been nudged to migrate', async () => { - startTestDrive(undefined, false, true, false, undefined, undefined, false, 2); + startTestDrive(undefined, true, false); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); }); it("should show the Test Drive demo if user doesn't have the nudge flag but is member of a paid policy", async () => { - startTestDrive(undefined, false, false, true, undefined, undefined, false, 2); + startTestDrive(undefined, false, true); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); @@ -86,14 +86,14 @@ describe('actions/Tour', () => { it.each(onboardingChoices.filter((choice) => onboardingDemoChoices.includes(choice)))('should show the Test Drive demo if user has "%s" onboarding choice', async (choice) => { await setTestDriveTaskData(); - startTestDrive({choice}, false, false, false, testDriveTaskReport, conciergeChatReport, false, accountID); + startTestDrive({choice}, false, false); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); }); it.each(onboardingChoices.filter((choice) => !onboardingDemoChoices.includes(choice)))('should show the Test Drive modal if user has "%s" onboarding choice', async (choice) => { - startTestDrive({choice}, false, false, false, undefined, undefined, false, accountID); + startTestDrive({choice}, false, false); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_MODAL_ROOT.route); @@ -102,23 +102,14 @@ describe('actions/Tour', () => { it('should show the Test Drive demo if user is an invited employee', async () => { await setTestDriveTaskData(); - startTestDrive( - {choice: CONST.ONBOARDING_CHOICES.SUBMIT, inviteType: CONST.ONBOARDING_INVITE_TYPES.WORKSPACE}, - false, - false, - false, - testDriveTaskReport, - conciergeChatReport, - false, - accountID, - ); + startTestDrive({choice: CONST.ONBOARDING_CHOICES.SUBMIT, inviteType: CONST.ONBOARDING_INVITE_TYPES.WORKSPACE}, false, false); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); }); it('should show the Test Drive demo if user is member of a paid policy', async () => { - startTestDrive({choice: CONST.ONBOARDING_CHOICES.LOOKING_AROUND}, false, false, true, testDriveTaskReport, conciergeChatReport, false, accountID); + startTestDrive({choice: CONST.ONBOARDING_CHOICES.LOOKING_AROUND}, false, true); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.TEST_DRIVE_DEMO_ROOT); From 46e908dda48815b4f6b845e93d4d03e3a7af4076 Mon Sep 17 00:00:00 2001 From: paulnjs Date: Wed, 29 Oct 2025 19:24:05 +0700 Subject: [PATCH 2/2] fix lint --- src/components/TestDrive/TestDriveDemo.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/TestDrive/TestDriveDemo.tsx b/src/components/TestDrive/TestDriveDemo.tsx index 8cd4811e0eecf..eb44c2502945c 100644 --- a/src/components/TestDrive/TestDriveDemo.tsx +++ b/src/components/TestDrive/TestDriveDemo.tsx @@ -49,9 +49,7 @@ function TestDriveDemo() { if (hasSeenTour) { return; } - InteractionManager.runAfterInteractions(() => { - completeTestDriveTask(viewTourTaskReport, viewTourTaskParentReport, isViewTourTaskParentReportArchived, currentUserPersonalDetails.accountID); - }); + completeTestDriveTask(viewTourTaskReport, viewTourTaskParentReport, isViewTourTaskParentReportArchived, currentUserPersonalDetails.accountID); }, [hasSeenTour]); useEffect(() => {