diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index a43f1622ec9a..86d4c90d67ed 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -890,8 +890,7 @@ type OnyxValuesMapping = { [ONYXKEYS.ACCOUNT_MANAGER_REPORT_ID]: string; [ONYXKEYS.NVP_IS_FIRST_TIME_NEW_EXPENSIFY_USER]: boolean; - // NVP_ONBOARDING is an array for old users. - [ONYXKEYS.NVP_ONBOARDING]: Onboarding | []; + [ONYXKEYS.NVP_ONBOARDING]: Onboarding; // ONYXKEYS.NVP_TRYNEWDOT is HybridApp onboarding data [ONYXKEYS.NVP_TRYNEWDOT]: OnyxTypes.TryNewDot; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7e0f983b3e9e..e9c017db43ce 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -736,7 +736,7 @@ Onyx.connect({ }, }); -let onboarding: OnyxEntry; +let onboarding: OnyxEntry; Onyx.connect({ key: ONYXKEYS.NVP_ONBOARDING, callback: (value) => (onboarding = value), @@ -8352,8 +8352,8 @@ function shouldShowMerchantColumn(transactions: Transaction[]) { * only use the Concierge chat. */ function isChatUsedForOnboarding(optionOrReport: OnyxEntry | OptionData): 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) { + // onboarding can be an empty object for old accounts and accounts created from olddot + if (onboarding && !isEmptyObject(onboarding) && onboarding.chatReportID) { return onboarding.chatReportID === optionOrReport?.reportID; } diff --git a/src/libs/actions/Welcome/OnboardingFlow.ts b/src/libs/actions/Welcome/OnboardingFlow.ts index 9aa0f07dc59c..d515d1333be4 100644 --- a/src/libs/actions/Welcome/OnboardingFlow.ts +++ b/src/libs/actions/Welcome/OnboardingFlow.ts @@ -30,7 +30,7 @@ Onyx.connect({ if (value === undefined) { return; } - onboardingValues = value as Onboarding; + onboardingValues = value; }, }); diff --git a/src/libs/actions/Welcome/index.ts b/src/libs/actions/Welcome/index.ts index b306daf444ba..fcb3916256d8 100644 --- a/src/libs/actions/Welcome/index.ts +++ b/src/libs/actions/Welcome/index.ts @@ -13,7 +13,7 @@ import type TryNewDot from '@src/types/onyx/TryNewDot'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import * as OnboardingFlow from './OnboardingFlow'; -type OnboardingData = Onboarding | [] | undefined; +type OnboardingData = Onboarding | undefined; let isLoadingReportData = true; let tryNewDotData: TryNewDot | undefined; @@ -44,7 +44,7 @@ function onServerDataReady(): Promise { let isOnboardingInProgress = false; function isOnboardingFlowCompleted({onCompleted, onNotCompleted, onCanceled}: HasCompletedOnboardingFlowProps) { isOnboardingFlowStatusKnownPromise.then(() => { - if (Array.isArray(onboarding) || isEmptyObject(onboarding) || onboarding?.hasCompletedGuidedSetupFlow === undefined) { + if (isEmptyObject(onboarding) || onboarding?.hasCompletedGuidedSetupFlow === undefined) { onCanceled?.(); return; } diff --git a/src/libs/onboardingSelectors.ts b/src/libs/onboardingSelectors.ts index 91185e5c67bf..b21626cf8a07 100644 --- a/src/libs/onboardingSelectors.ts +++ b/src/libs/onboardingSelectors.ts @@ -11,7 +11,7 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject'; */ function hasCompletedGuidedSetupFlowSelector(onboarding: OnyxValue): boolean | undefined { // Onboarding is an empty object for old accounts and accounts migrated from OldDot - if (Array.isArray(onboarding) || isEmptyObject(onboarding)) { + if (isEmptyObject(onboarding)) { return true; } @@ -49,7 +49,7 @@ function tryNewDotOnyxSelector(tryNewDotData: OnyxValue): boolean | undefined { - if (Array.isArray(onboarding) || isEmptyObject(onboarding)) { + if (isEmptyObject(onboarding)) { return false; } diff --git a/tests/unit/OnboardingSelectorsTest.ts b/tests/unit/OnboardingSelectorsTest.ts index 1fc5846b2472..3cfd4d112ccc 100644 --- a/tests/unit/OnboardingSelectorsTest.ts +++ b/tests/unit/OnboardingSelectorsTest.ts @@ -7,11 +7,6 @@ describe('onboardingSelectors', () => { // Not all users have this NVP defined as we did not run a migration to backfill it for existing accounts, hence we need to make sure // the onboarding flow is only showed to the users with `hasCompletedGuidedSetupFlow` set to false describe('hasCompletedGuidedSetupFlowSelector', () => { - // It might be the case that backend returns an empty array if the NVP is not defined on this particular account - it('Should return true if onboarding NVP is an array', () => { - const onboarding = [] as OnyxValue; - expect(hasCompletedGuidedSetupFlowSelector(onboarding)).toBe(true); - }); it('Should return true if onboarding NVP is an empty object', () => { const onboarding = {} as OnyxValue; expect(hasCompletedGuidedSetupFlowSelector(onboarding)).toBe(true);