Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: back button after deleting expense #44537

9 changes: 7 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3559,7 +3559,7 @@ function goBackToDetailsPage(report: OnyxEntry<Report>) {
Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(report?.reportID ?? '-1'));
}

function navigateBackAfterDeleteTransaction(backRoute: Route | undefined) {
function navigateBackAfterDeleteTransaction(backRoute: Route | undefined, isFromRHP?: boolean) {
if (!backRoute) {
return;
}
Expand All @@ -3568,7 +3568,12 @@ function navigateBackAfterDeleteTransaction(backRoute: Route | undefined) {
Navigation.dismissModal();
return;
}
Navigation.goBack(backRoute);
if (isFromRHP) {
Navigation.dismissModal();
}
Navigation.isNavigationReady().then(() => {
Navigation.goBack(backRoute);
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
isVisible={isDeleteModalVisible}
onConfirm={deleteTransaction}
onCancel={() => setIsDeleteModalVisible(false)}
onModalHide={() => ReportUtils.navigateBackAfterDeleteTransaction(navigateBackToAfterDelete.current)}
onModalHide={() => ReportUtils.navigateBackAfterDeleteTransaction(navigateBackToAfterDelete.current, true)}
prompt={caseID === CASES.DEFAULT ? translate('task.deleteConfirmation') : translate('iou.deleteConfirmation')}
confirmText={translate('common.delete')}
cancelText={translate('common.cancel')}
Expand Down
Loading