Skip to content

Commit 669d6d4

Browse files
committed
fixed proper navigations after creating reports
1 parent 47fee90 commit 669d6d4

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';
@@ -198,13 +199,19 @@ function IOURequestStepUpgrade({
198199
}
199200
case CONST.UPGRADE_PATHS.REPORTS:
200201
if (action === CONST.IOU.ACTION.CREATE && policyID) {
201-
// Coming from "Create report" (no workspace) — create directly with the just-created
202-
// workspace. forceReplace removes the upgrade screen from history so back returns to
203-
// the originating screen, not the upgrade step.
202+
// "Create report" with no workspace: open the report where the user started.
204203
const {reportID: newReportID} = createReportForCurrentUser(policyID);
205-
Navigation.setNavigationActionToMicrotaskQueue(() => {
206-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(newReportID), {forceReplace: true});
207-
});
204+
if (isSearchTopmostFullScreenRoute()) {
205+
// Spend/Search tab: replace the upgrade screen within the RHP (same navigator,
206+
// so forceReplace holds). Back returns to Spend > Reports.
207+
Navigation.setNavigationActionToMicrotaskQueue(() => {
208+
Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID: newReportID}), {forceReplace: true});
209+
});
210+
} else {
211+
// Elsewhere (e.g. FAB): dismiss the upgrade RHP first, then open in Inbox,
212+
// so back doesn't return to the upgrade step.
213+
Navigation.dismissModalWithReport({reportID: newReportID});
214+
}
208215
} else {
209216
Navigation.goBack();
210217
navigateWithMicrotask(ROUTES.MONEY_REQUEST_STEP_REPORT.getRoute(action, CONST.IOU.TYPE.SUBMIT, transactionID, reportID));

0 commit comments

Comments
 (0)