Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState} from 'react';
import React, {useMemo, useState} from 'react';
import usePermissions from '@hooks/usePermissions';
import createSplitNavigator from '@libs/Navigation/AppNavigator/createSplitNavigator';
import FreezeWrapper from '@libs/Navigation/AppNavigator/FreezeWrapper';
Expand All @@ -11,6 +11,7 @@ import type {AuthScreensParamList, ReportsSplitNavigatorParamList} from '@libs/N
import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import type NAVIGATORS from '@src/NAVIGATORS';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type ReactComponentModule from '@src/types/utils/ReactComponentModule';

Expand All @@ -26,13 +27,25 @@ function ReportsSplitNavigator({route}: PlatformStackScreenProps<AuthScreensPara
const {isBetaEnabled} = usePermissions();
const splitNavigatorScreenOptions = useSplitNavigatorScreenOptions();

// Determine if the current URL indicates a transition.
const isTransitioning = useMemo(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this memo would be useless when we turn on the React Compiler so I wonder if we need it here. Probably good for now ✅

const currentURL = getCurrentUrl();
return currentURL.includes(ROUTES.TRANSITION_BETWEEN_APPS);
}, []);

const [initialReportID] = useState(() => {
const currentURL = getCurrentUrl();
const reportIdFromPath = currentURL && new URL(currentURL).pathname.match(CONST.REGEX.REPORT_ID_FROM_PATH)?.at(1);
if (reportIdFromPath) {
return reportIdFromPath;
}

// If we are in a transition, we explicitly do NOT want to load the last accessed report.
// Returning an empty string here will cause ReportScreen to skip the `openReport` call initially.
if (isTransitioning) {
return '';
}

const initialReport = ReportUtils.findLastAccessedReport(!isBetaEnabled(CONST.BETAS.DEFAULT_ROOMS), shouldOpenOnAdminRoom());
// eslint-disable-next-line rulesdir/no-default-id-values
return initialReport?.reportID ?? '';
Expand Down
Loading