Skip to content
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
7 changes: 4 additions & 3 deletions src/libs/navigateAfterOnboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -25,8 +25,9 @@ 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)) {
// When the user goes through the onboarding flow, a workspace can be created if the user selects specific options. The user should be taken to the #admins room for that workspace because it is the most natural place for them to start their experience in the app.
// The user should never go to the self DM or the Concierge chat if a workspace was created during the onboarding flow.
if (lastAccessedReportID && lastAccessedReport.policyID !== onboardingPolicyID && !isConciergeChatReport(lastAccessedReport) && !isSelfDM(lastAccessedReport)) {
reportID = lastAccessedReportID;
}
}
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/navigateAfterOnboardingTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jest.mock('@libs/ReportUtils', () => ({
shouldDisplayViolationsRBRInLHN: jest.requireActual<typeof ReportUtils>('@libs/ReportUtils').shouldDisplayViolationsRBRInLHN,
generateIsEmptyReport: jest.requireActual<typeof ReportUtils>('@libs/ReportUtils').generateIsEmptyReport,
isExpenseReport: jest.requireActual<typeof ReportUtils>('@libs/ReportUtils').isExpenseReport,
isSelfDM: jest.requireActual<typeof ReportUtils>('@libs/ReportUtils').isSelfDM,
}));

jest.mock('@libs/Navigation/helpers/shouldOpenOnAdminRoom', () => ({
Expand Down Expand Up @@ -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};
Expand Down
Loading