From 2b8b18b1892004ff1f5c22258ed6060714472ec9 Mon Sep 17 00:00:00 2001 From: dominictb Date: Sat, 13 Jul 2024 17:54:46 +0700 Subject: [PATCH 1/2] fix: open the correct chat during onboarding flow Signed-off-by: dominictb --- src/libs/ReportUtils.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index f7dca71fd15f..aeaf8b85097d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -57,6 +57,7 @@ import * as SessionUtils from './actions/Session'; import * as CurrencyUtils from './CurrencyUtils'; import DateUtils from './DateUtils'; import {hasValidDraftComment} from './DraftCommentUtils'; +import getIsSmallScreenWidth from './getIsSmallScreenWidth'; import isReportMessageAttachment from './isReportMessageAttachment'; import localeCompare from './LocaleCompare'; import * as LocalePhoneNumber from './LocalePhoneNumber'; @@ -1236,6 +1237,12 @@ function findLastAccessedReport(ignoreDomainRooms: boolean, openOnAdminRoom = fa return adminReport ?? reportsValues.find((report) => !isConciergeChatReport(report)); } + // if the user hasn't completed the onboarding flow, whether the user should be in the concierge chat or system chat + // should be consistent with what chat the user will land after onboarding flow + if (!getIsSmallScreenWidth() && !Array.isArray(onboarding) && !onboarding?.hasCompletedGuidedSetupFlow) { + return reportsValues.find(isChatUsedForOnboarding); + } + // If we only have two reports and one of them is the system chat, filter it out so we don't // overwrite showing the concierge chat const hasSystemChat = reportsValues.find((report) => isSystemChat(report)) ?? false; From 46dba17da78ee54682a2acd12bb7c26efa2994b3 Mon Sep 17 00:00:00 2001 From: dominictb Date: Fri, 19 Jul 2024 15:21:55 +0700 Subject: [PATCH 2/2] fix: move the condition to the top Signed-off-by: dominictb --- src/libs/ReportUtils.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index d9f284cdb495..5dba4598ace2 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1225,6 +1225,12 @@ function findLastAccessedReport(ignoreDomainRooms: boolean, openOnAdminRoom = fa }); } + // if the user hasn't completed the onboarding flow, whether the user should be in the concierge chat or system chat + // should be consistent with what chat the user will land after onboarding flow + if (!getIsSmallScreenWidth() && !Array.isArray(onboarding) && !onboarding?.hasCompletedGuidedSetupFlow) { + return reportsValues.find(isChatUsedForOnboarding); + } + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const shouldFilter = excludeReportID || ignoreDomainRooms; if (shouldFilter) { @@ -1259,12 +1265,6 @@ function findLastAccessedReport(ignoreDomainRooms: boolean, openOnAdminRoom = fa return adminReport ?? reportsValues.find((report) => !isConciergeChatReport(report)); } - // if the user hasn't completed the onboarding flow, whether the user should be in the concierge chat or system chat - // should be consistent with what chat the user will land after onboarding flow - if (!getIsSmallScreenWidth() && !Array.isArray(onboarding) && !onboarding?.hasCompletedGuidedSetupFlow) { - return reportsValues.find(isChatUsedForOnboarding); - } - // If we only have two reports and one of them is the system chat, filter it out so we don't // overwrite showing the concierge chat const hasSystemChat = reportsValues.find((report) => isSystemChat(report)) ?? false;