Skip to content

Commit d25c9f9

Browse files
authored
Merge pull request Expensify#90928 from mukhrr/fix/create-report-regressions
[CP Stg] fixed proper navigations after creating reports
2 parents 6ebfa49 + 669d6d4 commit d25c9f9

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

src/pages/iou/request/step/IOURequestStepUpgrade.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {createNewReport} from '@libs/actions/Report';
2424
import {changeTransactionsReport, setTransactionReport} from '@libs/actions/Transaction';
2525
import type CreateWorkspaceParams from '@libs/API/parameters/CreateWorkspaceParams';
2626
import getPlatform from '@libs/getPlatform';
27+
import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute';
2728
import Navigation from '@libs/Navigation/Navigation';
2829
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
2930
import type {MoneyRequestNavigatorParamList} from '@libs/Navigation/types';
@@ -197,13 +198,19 @@ function IOURequestStepUpgrade({
197198
}
198199
case CONST.UPGRADE_PATHS.REPORTS:
199200
if (action === CONST.IOU.ACTION.CREATE && policyID) {
200-
// Coming from "Create report" (no workspace) — create directly with the just-created
201-
// workspace. forceReplace removes the upgrade screen from history so back returns to
202-
// the originating screen, not the upgrade step.
201+
// "Create report" with no workspace: open the report where the user started.
203202
const {reportID: newReportID} = createReportForCurrentUser(policyID);
204-
Navigation.setNavigationActionToMicrotaskQueue(() => {
205-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(newReportID), {forceReplace: true});
206-
});
203+
if (isSearchTopmostFullScreenRoute()) {
204+
// Spend/Search tab: replace the upgrade screen within the RHP (same navigator,
205+
// so forceReplace holds). Back returns to Spend > Reports.
206+
Navigation.setNavigationActionToMicrotaskQueue(() => {
207+
Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID: newReportID}), {forceReplace: true});
208+
});
209+
} else {
210+
// Elsewhere (e.g. FAB): dismiss the upgrade RHP first, then open in Inbox,
211+
// so back doesn't return to the upgrade step.
212+
Navigation.dismissModalWithReport({reportID: newReportID});
213+
}
207214
} else {
208215
Navigation.goBack();
209216
navigateWithMicrotask(ROUTES.MONEY_REQUEST_STEP_REPORT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, reportID));

0 commit comments

Comments
 (0)