From 2c8185dfe4c2bfb3cbb945c08a3527eaaa8f1d9b Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Tue, 28 Oct 2025 11:25:52 +0700 Subject: [PATCH 1/3] fix: New user is dropped in self dm first after creating a workspace during onboarding --- src/libs/navigateAfterOnboarding.ts | 6 +++--- tests/unit/navigateAfterOnboardingTest.ts | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/libs/navigateAfterOnboarding.ts b/src/libs/navigateAfterOnboarding.ts index 7c02ad4d5ced..6f86ac8b9f63 100644 --- a/src/libs/navigateAfterOnboarding.ts +++ b/src/libs/navigateAfterOnboarding.ts @@ -2,7 +2,7 @@ import ROUTES from '@src/ROUTES'; import {setDisableDismissOnEscape} from './actions/Modal'; import shouldOpenOnAdminRoom from './Navigation/helpers/shouldOpenOnAdminRoom'; import Navigation from './Navigation/Navigation'; -import {findLastAccessedReport, isConciergeChatReport} from './ReportUtils'; +import {findLastAccessedReport, isConciergeChatReport, isSelfDM} from './ReportUtils'; const navigateAfterOnboarding = ( isSmallScreenWidth: boolean, @@ -26,8 +26,8 @@ const navigateAfterOnboarding = ( } else { const lastAccessedReport = findLastAccessedReport(!canUseDefaultRooms, shouldOpenOnAdminRoom() && !shouldPreventOpenAdminRoom); const lastAccessedReportID = lastAccessedReport?.reportID; - // we don't want to navigate to newly created workspaces after onboarding is completed. - if (lastAccessedReportID && lastAccessedReport.policyID !== onboardingPolicyID && !isConciergeChatReport(lastAccessedReport)) { + // we don't want to navigate to newly created workspaces/selfDM after onboarding is completed. + if (lastAccessedReportID && lastAccessedReport.policyID !== onboardingPolicyID && !isConciergeChatReport(lastAccessedReport) && !isSelfDM(lastAccessedReport)) { reportID = lastAccessedReportID; } } diff --git a/tests/unit/navigateAfterOnboardingTest.ts b/tests/unit/navigateAfterOnboardingTest.ts index b2accc2bd420..e49084b34a39 100644 --- a/tests/unit/navigateAfterOnboardingTest.ts +++ b/tests/unit/navigateAfterOnboardingTest.ts @@ -42,6 +42,7 @@ jest.mock('@libs/ReportUtils', () => ({ shouldDisplayViolationsRBRInLHN: jest.requireActual('@libs/ReportUtils').shouldDisplayViolationsRBRInLHN, generateIsEmptyReport: jest.requireActual('@libs/ReportUtils').generateIsEmptyReport, isExpenseReport: jest.requireActual('@libs/ReportUtils').isExpenseReport, + isSelfDM: jest.requireActual('@libs/ReportUtils').isSelfDM, })); jest.mock('@libs/Navigation/helpers/shouldOpenOnAdminRoom', () => ({ @@ -104,6 +105,15 @@ describe('navigateAfterOnboarding', () => { expect(Navigation.navigate).not.toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(REPORT_ID)); }); + it('should not navigate to last accessed report if it is selfDM chat on small screens', () => { + const lastAccessedReport = {reportID: REPORT_ID, chatType: CONST.REPORT.CHAT_TYPE.SELF_DM}; + mockFindLastAccessedReport.mockReturnValue(lastAccessedReport); + mockShouldOpenOnAdminRoom.mockReturnValue(false); + + navigateAfterOnboarding(true, true, ONBOARDING_POLICY_ID, ONBOARDING_ADMINS_CHAT_REPORT_ID); + expect(Navigation.navigate).not.toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(REPORT_ID)); + }); + it('should navigate to last accessed report if shouldOpenOnAdminRoom is true on small screens', () => { const navigate = jest.spyOn(Navigation, 'navigate'); const lastAccessedReport = {reportID: REPORT_ID}; From 02bd21d074992849728e83ab4259a17e2289996f Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Thu, 30 Oct 2025 20:36:25 +0700 Subject: [PATCH 2/3] provide more detailed explaination --- src/libs/navigateAfterOnboarding.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/navigateAfterOnboarding.ts b/src/libs/navigateAfterOnboarding.ts index 6f86ac8b9f63..06eafece7a39 100644 --- a/src/libs/navigateAfterOnboarding.ts +++ b/src/libs/navigateAfterOnboarding.ts @@ -26,7 +26,7 @@ const navigateAfterOnboarding = ( } else { const lastAccessedReport = findLastAccessedReport(!canUseDefaultRooms, shouldOpenOnAdminRoom() && !shouldPreventOpenAdminRoom); const lastAccessedReportID = lastAccessedReport?.reportID; - // we don't want to navigate to newly created workspaces/selfDM after onboarding is completed. + // We need to send the user to the #admins room from the policy that was created while onboarding, instead of navigating to newly created workspaces/selfDM after onboarding is completed. if (lastAccessedReportID && lastAccessedReport.policyID !== onboardingPolicyID && !isConciergeChatReport(lastAccessedReport) && !isSelfDM(lastAccessedReport)) { reportID = lastAccessedReportID; } From 19a364c507b1ed29d44cbba46b56c44fdf69204c Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Thu, 30 Oct 2025 20:37:02 +0700 Subject: [PATCH 3/3] provide more detailed explaination --- src/libs/navigateAfterOnboarding.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/navigateAfterOnboarding.ts b/src/libs/navigateAfterOnboarding.ts index 06eafece7a39..e39cda460abb 100644 --- a/src/libs/navigateAfterOnboarding.ts +++ b/src/libs/navigateAfterOnboarding.ts @@ -26,7 +26,8 @@ const navigateAfterOnboarding = ( } else { const lastAccessedReport = findLastAccessedReport(!canUseDefaultRooms, shouldOpenOnAdminRoom() && !shouldPreventOpenAdminRoom); const lastAccessedReportID = lastAccessedReport?.reportID; - // We need to send the user to the #admins room from the policy that was created while onboarding, instead of navigating to newly created workspaces/selfDM after onboarding is completed. + // We need to send the user to the #admins room from the policy that was created while onboarding, not newly created workspaces nor selfDM chats + // See https://github.com/Expensify/App/issues/61417 and https://github.com/Expensify/App/issues/73559 for more details. if (lastAccessedReportID && lastAccessedReport.policyID !== onboardingPolicyID && !isConciergeChatReport(lastAccessedReport) && !isSelfDM(lastAccessedReport)) { reportID = lastAccessedReportID; }