Skip to content

Commit f9942f1

Browse files
authored
Merge pull request #61544 from nkdengineer/fix/60679-add-backto
Inconsistent Report Header and Navigation after refreshing details page
2 parents 0bba689 + ee20787 commit f9942f1

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

src/components/ReportActionItem/MoneyRequestAction.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ function MoneyRequestAction({
7474
isWhisper = false,
7575
shouldDisplayContextMenu = true,
7676
}: MoneyRequestActionProps) {
77-
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`);
78-
const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${requestReportID}`);
79-
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReportID}`, {canEvict: false});
77+
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`, {canBeMissing: true});
78+
const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${requestReportID}`, {canBeMissing: true});
79+
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReportID}`, {canEvict: false, canBeMissing: true});
8080

8181
const styles = useThemeStyles();
8282
const {translate} = useLocalize();
@@ -98,11 +98,11 @@ function MoneyRequestAction({
9898
const transactionID = isMoneyRequestAction(action) ? getOriginalMessage(action)?.IOUTransactionID : CONST.DEFAULT_NUMBER_ID;
9999
if (!action?.childReportID && transactionID && action.reportActionID) {
100100
const optimisticReportID = generateReportID();
101-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(optimisticReportID, undefined, undefined, action.reportActionID, transactionID));
101+
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(optimisticReportID, undefined, undefined, action.reportActionID, transactionID, Navigation.getActiveRoute()));
102102
return;
103103
}
104104

105-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(action?.childReportID));
105+
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(action?.childReportID, undefined, undefined, undefined, undefined, Navigation.getActiveRoute()));
106106
};
107107

108108
let shouldShowPendingConversionMessage = false;

src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ function MoneyRequestReportPreviewContent({
447447
}
448448
Performance.markStart(CONST.TIMING.OPEN_REPORT_FROM_PREVIEW);
449449
Timing.start(CONST.TIMING.OPEN_REPORT_FROM_PREVIEW);
450-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReportID));
450+
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReportID, undefined, undefined, undefined, undefined, Navigation.getActiveRoute()));
451451
}, [iouReportID]);
452452

453453
const reportPreviewAction = useMemo(() => {

src/components/ReportActionItem/MoneyRequestReportPreview/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function MoneyRequestReportPreview({
8080

8181
Performance.markStart(CONST.TIMING.OPEN_REPORT_FROM_PREVIEW);
8282
Timing.start(CONST.TIMING.OPEN_REPORT_FROM_PREVIEW);
83-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReportID));
83+
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReportID, undefined, undefined, undefined, undefined, Navigation.getActiveRoute()));
8484
}, [iouReportID]);
8585

8686
const renderItem: ListRenderItem<Transaction> = ({item}) => (

src/components/ReportActionItem/ReportPreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ function ReportPreview({
506506
}
507507
Performance.markStart(CONST.TIMING.OPEN_REPORT_FROM_PREVIEW);
508508
Timing.start(CONST.TIMING.OPEN_REPORT_FROM_PREVIEW);
509-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReportID));
509+
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReportID, undefined, undefined, undefined, undefined, Navigation.getActiveRoute()));
510510
}, [iouReportID]);
511511

512512
const reportPreviewAction = useMemo(() => {

src/components/ReportActionItem/ReportPreviewOld.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ function ReportPreviewOld({
503503
}
504504
Performance.markStart(CONST.TIMING.OPEN_REPORT_FROM_PREVIEW);
505505
Timing.start(CONST.TIMING.OPEN_REPORT_FROM_PREVIEW);
506-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReportID));
506+
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(iouReportID, undefined, undefined, undefined, undefined, Navigation.getActiveRoute()));
507507
}, [iouReportID]);
508508

509509
const buttonType = getIOUReportPreviewButtonType({

src/components/ReportActionItem/TaskPreview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function TaskPreview({
7777
const StyleUtils = useStyleUtils();
7878
const {translate} = useLocalize();
7979
const theme = useTheme();
80-
const [taskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`);
80+
const [taskReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, {canBeMissing: true});
8181
const taskTitle = action?.childReportName ?? taskReport?.reportName ?? '';
8282

8383
const taskTitleWithoutImage = Parser.replace(Parser.htmlToMarkdown(taskTitle), {disabledRules: [...CONST.TASK_TITLE_DISABLED_RULES]});
@@ -113,7 +113,7 @@ function TaskPreview({
113113
return (
114114
<View style={[styles.chatItemMessage, !hasAssignee && styles.mv1]}>
115115
<PressableWithoutFeedback
116-
onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(taskReportID))}
116+
onPress={() => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(taskReportID, undefined, undefined, undefined, undefined, Navigation.getActiveRoute()))}
117117
onPressIn={() => canUseTouchScreen() && ControlSelection.block()}
118118
onPressOut={() => ControlSelection.unblock()}
119119
onLongPress={(event) => {

src/components/ReportActionItem/TripRoomPreview.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ function TripRoomPreview({
128128
}: TripRoomPreviewProps) {
129129
const styles = useThemeStyles();
130130
const {translate} = useLocalize();
131-
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`);
132-
const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReport?.iouReportID}`);
131+
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`, {canBeMissing: true});
132+
const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReport?.iouReportID}`, {canBeMissing: true});
133133
const tripTransactions = useTripTransactions(chatReportID);
134134

135135
const reservationsData: ReservationData[] = getReservationsFromTripTransactions(tripTransactions);
@@ -151,7 +151,7 @@ function TripRoomPreview({
151151
);
152152
}, [currency, totalDisplaySpend, tripTransactions]);
153153

154-
const navigateToTrip = () => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(chatReportID));
154+
const navigateToTrip = () => Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(chatReportID, undefined, undefined, undefined, undefined, Navigation.getActiveRoute()));
155155
const renderItem = ({item}: ListRenderItemInfo<ReservationData>) => (
156156
<ReservationView
157157
reservation={item.reservation}

src/libs/actions/Report.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ function navigateToAndOpenReportWithAccountIDs(participantAccountIDs: number[])
13841384
function navigateToAndOpenChildReport(childReportID: string | undefined, parentReportAction: Partial<ReportAction> = {}, parentReportID?: string) {
13851385
const childReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${childReportID}`];
13861386
if (childReport?.reportID) {
1387-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(childReportID));
1387+
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(childReportID, undefined, undefined, undefined, undefined, Navigation.getActiveRoute()));
13881388
} else {
13891389
const participantAccountIDs = [...new Set([currentUserAccountID, Number(parentReportAction.actorAccountID)])];
13901390
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${parentReportID}`];
@@ -1410,7 +1410,7 @@ function navigateToAndOpenChildReport(childReportID: string | undefined, parentR
14101410
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${childReportID}`, newChat);
14111411
}
14121412

1413-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(newChat.reportID));
1413+
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(newChat.reportID, undefined, undefined, undefined, undefined, Navigation.getActiveRoute()));
14141414
}
14151415
}
14161416

src/pages/home/report/PureReportActionItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ function PureReportActionItem({
829829
return;
830830
}
831831

832-
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(action.childReportID));
832+
Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(action.childReportID, undefined, undefined, undefined, undefined, Navigation.getActiveRoute()));
833833
}}
834834
isTrackExpense={isTrackExpenseActionReportActionsUtils(action)}
835835
/>

0 commit comments

Comments
 (0)