Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for empty object for the onboarding flow too #52175

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8244,8 +8244,8 @@ function shouldShowMerchantColumn(transactions: Transaction[]) {
* only use the Concierge chat.
*/
function isChatUsedForOnboarding(optionOrReport: OnyxEntry<Report> | OptionData): boolean {
// onboarding can be an array for old accounts and accounts created from olddot
if (onboarding && !Array.isArray(onboarding) && onboarding.chatReportID) {
// 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;
}

Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/Welcome/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {OnboardingCompanySizeType, OnboardingPurposeType} from '@src/CONST'
import ONYXKEYS from '@src/ONYXKEYS';
import type Onboarding from '@src/types/onyx/Onboarding';
import type TryNewDot from '@src/types/onyx/TryNewDot';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import * as OnboardingFlow from './OnboardingFlow';

type OnboardingData = Onboarding | [] | undefined;
Expand Down Expand Up @@ -41,7 +42,7 @@ function onServerDataReady(): Promise<void> {
let isOnboardingInProgress = false;
function isOnboardingFlowCompleted({onCompleted, onNotCompleted, onCanceled}: HasCompletedOnboardingFlowProps) {
isOnboardingFlowStatusKnownPromise.then(() => {
if (Array.isArray(onboarding) || onboarding?.hasCompletedGuidedSetupFlow === undefined) {
if (Array.isArray(onboarding) || isEmptyObject(onboarding) || onboarding?.hasCompletedGuidedSetupFlow === undefined) {
onCanceled?.();
return;
}
Expand Down
9 changes: 5 additions & 4 deletions src/libs/onboardingSelectors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {OnyxValue} from 'react-native-onyx';
import type ONYXKEYS from '@src/ONYXKEYS';
import {isEmptyObject} from '@src/types/utils/EmptyObject';

/**
* Selector to get the value of hasCompletedGuidedSetupFlow from the Onyx store
Expand All @@ -9,8 +10,8 @@ import type ONYXKEYS from '@src/ONYXKEYS';
* `false` means the user has not completed the NewDot onboarding flow
*/
function hasCompletedGuidedSetupFlowSelector(onboarding: OnyxValue<typeof ONYXKEYS.NVP_ONBOARDING>): boolean | undefined {
// Onboarding is an array for old accounts and accounts created from OldDot
if (Array.isArray(onboarding)) {
// Onboarding is an array or an empty object for old accounts and accounts created from OldDot
if (Array.isArray(onboarding) || isEmptyObject(onboarding)) {
MonilBhavsar marked this conversation as resolved.
Show resolved Hide resolved
return true;
}

Expand Down Expand Up @@ -43,11 +44,11 @@ function hasCompletedHybridAppOnboardingFlowSelector(tryNewDotData: OnyxValue<ty
* `false` means the user has not completed the NewDot onboarding flow
*/
function hasSeenTourSelector(onboarding: OnyxValue<typeof ONYXKEYS.NVP_ONBOARDING>): boolean | undefined {
if (Array.isArray(onboarding)) {
if (Array.isArray(onboarding) || isEmptyObject(onboarding)) {
MonilBhavsar marked this conversation as resolved.
Show resolved Hide resolved
return false;
}

return onboarding?.selfTourViewed;
return !!onboarding?.selfTourViewed;
}

export {hasCompletedGuidedSetupFlowSelector, hasCompletedHybridAppOnboardingFlowSelector, hasSeenTourSelector};
Loading