From 95a6042e2f6c7b2c11ecd01f265244a5a69b6f19 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Tue, 30 Sep 2025 15:56:44 +0530 Subject: [PATCH 1/2] Ensure test drive modal doesn't show again if it has been dismissed --- src/libs/actions/Report.ts | 35 ++++++++++++++++++---------------- tests/actions/ReportTest.ts | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 9e06930afa7c..42bc1afd99d1 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -4,7 +4,7 @@ import {Str} from 'expensify-common'; import isEmpty from 'lodash/isEmpty'; import {DeviceEventEmitter, InteractionManager, Linking} from 'react-native'; import type {NullishDeep, OnyxCollection, OnyxCollectionInputValue, OnyxEntry, OnyxUpdate} from 'react-native-onyx'; -import Onyx from 'react-native-onyx'; +import Onyx, { useOnyx } from 'react-native-onyx'; import type {PartialDeep, ValueOf} from 'type-fest'; import type {Emoji} from '@assets/emojis/types'; import type {LocaleContextProps} from '@components/LocaleContextProvider'; @@ -4337,24 +4337,27 @@ function completeOnboarding({ // Only add the dismissed state of the test drive modal when the user is not redirected to oldDot, // because we don't want the modal to reappear when returning from oldDot. + // We should only set testDriveModalDismissed to false if it's not already true (i.e., if the modal hasn't been dismissed yet). if (!shouldSkipTestDriveModal && !(engagementChoice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM && willRedirectToOldDotFromOnboarding)) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.NVP_ONBOARDING, - value: {testDriveModalDismissed: false}, - }); + if (onboarding?.testDriveModalDismissed !== true) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.NVP_ONBOARDING, + value: {testDriveModalDismissed: false}, + }); - successData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.NVP_ONBOARDING, - value: {testDriveModalDismissed: false}, - }); + successData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.NVP_ONBOARDING, + value: {testDriveModalDismissed: false}, + }); - failureData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: ONYXKEYS.NVP_ONBOARDING, - value: {testDriveModalDismissed: null}, - }); + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.NVP_ONBOARDING, + value: {testDriveModalDismissed: null}, + }); + } } API.write(WRITE_COMMANDS.COMPLETE_GUIDED_SETUP, parameters, {optimisticData, successData, failureData}); diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 88b4d946bd0f..aabff9f20b02 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -2298,4 +2298,42 @@ describe('actions/Report', () => { expect(upperCaseRequest?.data?.searchInput).toBe(lowerCaseRequest?.data?.searchInput); }); }); + + it('should not overwrite testDriveModalDismissed when it is already true', async () => { + const TEST_USER_ACCOUNT_ID = 1; + const TEST_USER_LOGIN = 'test@test.com'; + + await Onyx.set(ONYXKEYS.SESSION, {email: TEST_USER_LOGIN, accountID: TEST_USER_ACCOUNT_ID}); + await Onyx.set(ONYXKEYS.NVP_ONBOARDING, {testDriveModalDismissed: true}); + await waitForBatchedUpdates(); + + const adminsChatReportID = '7957055873634067'; + const onboardingPolicyID = 'A70D00C752416807'; + const engagementChoice = CONST.INTRO_CHOICES.MANAGE_TEAM; + const {onboardingMessages} = getOnboardingMessages(); + + Report.completeOnboarding({ + engagementChoice, + onboardingMessage: onboardingMessages[engagementChoice], + adminsChatReportID, + onboardingPolicyID, + companySize: CONST.ONBOARDING_COMPANY_SIZE.MICRO, + userReportedIntegration: null, + }); + + await waitForBatchedUpdates(); + + const onboarding = await new Promise>((resolve) => { + const connection = Onyx.connect({ + key: ONYXKEYS.NVP_ONBOARDING, + callback: (data) => { + Onyx.disconnect(connection); + resolve(data); + }, + }); + }); + + // testDriveModalDismissed should remain true and not be overwritten to false + expect(onboarding?.testDriveModalDismissed).toBe(true); + }); }); From 7f2af06a412f0620c2ddf6b41610462a05ecf7fd Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Tue, 30 Sep 2025 18:33:14 +0530 Subject: [PATCH 2/2] Lint and prettier fixes --- src/libs/actions/Report.ts | 2 +- tests/actions/ReportTest.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 42bc1afd99d1..cfb1c454a06f 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -4,7 +4,7 @@ import {Str} from 'expensify-common'; import isEmpty from 'lodash/isEmpty'; import {DeviceEventEmitter, InteractionManager, Linking} from 'react-native'; import type {NullishDeep, OnyxCollection, OnyxCollectionInputValue, OnyxEntry, OnyxUpdate} from 'react-native-onyx'; -import Onyx, { useOnyx } from 'react-native-onyx'; +import Onyx from 'react-native-onyx'; import type {PartialDeep, ValueOf} from 'type-fest'; import type {Emoji} from '@assets/emojis/types'; import type {LocaleContextProps} from '@components/LocaleContextProvider'; diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index aabff9f20b02..fce1db6afa2f 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -2302,7 +2302,7 @@ describe('actions/Report', () => { it('should not overwrite testDriveModalDismissed when it is already true', async () => { const TEST_USER_ACCOUNT_ID = 1; const TEST_USER_LOGIN = 'test@test.com'; - + await Onyx.set(ONYXKEYS.SESSION, {email: TEST_USER_LOGIN, accountID: TEST_USER_ACCOUNT_ID}); await Onyx.set(ONYXKEYS.NVP_ONBOARDING, {testDriveModalDismissed: true}); await waitForBatchedUpdates();