diff --git a/config/eslint/eslint.seatbelt.tsv b/config/eslint/eslint.seatbelt.tsv index 8b5407c29c12..bb92c04fb8f5 100644 --- a/config/eslint/eslint.seatbelt.tsv +++ b/config/eslint/eslint.seatbelt.tsv @@ -65,7 +65,7 @@ "../../src/Expensify.tsx" "react-hooks/set-state-in-effect" 1 "../../src/GlobalModals.tsx" "no-restricted-syntax" 2 "../../src/ONYXKEYS.ts" "no-restricted-syntax" 2 -"../../src/ROUTES.ts" "@typescript-eslint/no-deprecated/getUrlWithBackToParam" 104 +"../../src/ROUTES.ts" "@typescript-eslint/no-deprecated/getUrlWithBackToParam" 105 "../../src/ROUTES.ts" "@typescript-eslint/no-unsafe-type-assertion" 3 "../../src/TIMEZONES.ts" "@typescript-eslint/no-unsafe-type-assertion" 1 "../../src/components/AccountingConnectionConfirmationModal.tsx" "@typescript-eslint/no-deprecated/ConfirmModal" 1 diff --git a/src/ROUTES.ts b/src/ROUTES.ts index f7b9df0bae9d..3b24a721cf97 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -1695,6 +1695,7 @@ const ROUTES = { getRoute: (reportID: string | undefined, reportActionID?: string, referrer?: string, backTo?: string) => { if (!reportID) { Log.warn('Invalid reportID is used to build the REPORT_WITH_ID route'); + return getUrlWithBackToParam(ROUTES.HOME, backTo); } const baseRoute = reportActionID ? (`r/${reportID}/${reportActionID}` as const) : (`r/${reportID}` as const); diff --git a/tests/unit/navigateAfterOnboardingTest.ts b/tests/unit/navigateAfterOnboardingTest.ts index 312199815a36..634558a7f2d8 100644 --- a/tests/unit/navigateAfterOnboardingTest.ts +++ b/tests/unit/navigateAfterOnboardingTest.ts @@ -74,8 +74,11 @@ describe('navigateAfterOnboarding', () => { }); it('should not navigate to the admin room report if onboardingAdminsChatReportID is not provided on larger screens', () => { + const navigate = jest.spyOn(Navigation, 'navigate'); navigateAfterOnboarding(false, true, '', {}, undefined, undefined); - expect(Navigation.navigate).not.toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(undefined)); + // Without an admins chat report, we fall back to HOME to trigger guard evaluation instead of opening a report. + expect(navigate).not.toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(ONBOARDING_ADMINS_CHAT_REPORT_ID)); + expect(navigate).toHaveBeenCalledWith(ROUTES.HOME); }); it('should not navigate to last accessed report if it is a concierge chat on small screens', async () => {