From 5655d8e1a63045fc999d14edd2dcb09450002a61 Mon Sep 17 00:00:00 2001 From: Alberto Gonzalez-Cela Date: Thu, 14 Nov 2024 20:14:26 +0100 Subject: [PATCH] Merge pull request #52585 from software-mansion-labs/fix/guided-setup Fix that onboarding tasks are duplicated when switching chat (cherry picked from commit 93ae75f611515ef799b12216fdf8a47ddedd6503) (CP triggered by francoisl) --- src/libs/actions/Report.ts | 17 ++++++++++++++++- src/types/onyx/index.ts | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index f2b4186fa566..ec87dcb16df8 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -99,6 +99,7 @@ import type { IntroSelected, InvitedEmailsToAccountIDs, NewGroupChatDraft, + Onboarding, OnboardingPurpose, PersonalDetailsList, PolicyReportField, @@ -279,6 +280,17 @@ Onyx.connect({ callback: (val) => (quickAction = val), }); +let onboarding: OnyxEntry; +Onyx.connect({ + key: ONYXKEYS.NVP_ONBOARDING, + callback: (val) => { + if (Array.isArray(val)) { + return; + } + onboarding = val; + }, +}); + let introSelected: OnyxEntry = {}; Onyx.connect({ key: ONYXKEYS.NVP_INTRO_SELECTED, @@ -858,8 +870,11 @@ function openReport( }; const isInviteOnboardingComplete = introSelected?.isInviteOnboardingComplete ?? false; + const isOnboardingCompleted = onboarding?.hasCompletedGuidedSetupFlow ?? false; - if (introSelected && !isInviteOnboardingComplete) { + // Prepare guided setup data only when nvp_introSelected is set and onboarding is not completed + // OldDot users will never have nvp_introSelected set, so they will not see guided setup messages + if (introSelected && !isOnboardingCompleted && !isInviteOnboardingComplete) { const {choice, inviteType} = introSelected; const isInviteIOUorInvoice = inviteType === CONST.ONBOARDING_INVITE_TYPES.IOU || inviteType === CONST.ONBOARDING_INVITE_TYPES.INVOICE; const isInviteChoiceCorrect = choice === CONST.ONBOARDING_CHOICES.ADMIN || choice === CONST.ONBOARDING_CHOICES.SUBMIT || choice === CONST.ONBOARDING_CHOICES.CHAT_SPLIT; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index 79c2b4f230d4..cec5243990a6 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -41,6 +41,7 @@ import type MobileSelectionMode from './MobileSelectionMode'; import type Modal from './Modal'; import type Network from './Network'; import type NewGroupChatDraft from './NewGroupChatDraft'; +import type Onboarding from './Onboarding'; import type OnyxInputOrEntry from './OnyxInputOrEntry'; import type {OnyxUpdateEvent, OnyxUpdatesFromServer} from './OnyxUpdatesFromServer'; import type {DecisionName, OriginalMessageIOU} from './OriginalMessage'; @@ -237,6 +238,7 @@ export type { SaveSearch, RecentSearchItem, ImportedSpreadsheet, + Onboarding, OnboardingPurpose, ValidateMagicCodeAction, };