Skip to content

Commit

Permalink
Merge pull request #33041 from dukenv0307/fix/28969
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisl authored Dec 20, 2023
2 parents 8669b24 + 80196fc commit 463ca55
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ function ReportScreen({
const [listHeight, setListHeight] = useState(0);
const [scrollPosition, setScrollPosition] = useState({});

const wasReportAccessibleRef = useRef(false);
if (firstRenderRef.current) {
Timing.start(CONST.TIMING.CHAT_RENDER);
Performance.markStart(CONST.TIMING.CHAT_RENDER);
Expand Down Expand Up @@ -197,6 +198,13 @@ function ReportScreen({
const isTopMostReportId = currentReportID === getReportID(route);
const didSubscribeToReportLeavingEvents = useRef(false);

useEffect(() => {
if (!report || !report.reportID || shouldHideReport) {
return;
}
wasReportAccessibleRef.current = true;
}, [shouldHideReport, report]);

const goBack = useCallback(() => {
Navigation.goBack(ROUTES.HOME, false, true);
}, []);
Expand Down Expand Up @@ -341,7 +349,8 @@ function ReportScreen({
prevOnyxReportID === routeReportID &&
!onyxReportID &&
prevReport.statusNum === CONST.REPORT.STATUS.OPEN &&
(report.statusNum === CONST.REPORT.STATUS.CLOSED || (!report.statusNum && !prevReport.parentReportID && prevReport.chatType === CONST.REPORT.CHAT_TYPE.POLICY_ROOM)))
(report.statusNum === CONST.REPORT.STATUS.CLOSED || (!report.statusNum && !prevReport.parentReportID && prevReport.chatType === CONST.REPORT.CHAT_TYPE.POLICY_ROOM))) ||
((ReportUtils.isMoneyRequest(prevReport) || ReportUtils.isMoneyRequestReport(prevReport)) && _.isEmpty(report))
) {
Navigation.dismissModal();
if (Navigation.getTopmostReportId() === prevOnyxReportID) {
Expand All @@ -366,7 +375,19 @@ function ReportScreen({

fetchReportIfNeeded();
ComposerActions.setShouldShowComposeInput(true);
}, [route, report, errors, fetchReportIfNeeded, prevReport.reportID, prevUserLeavingStatus, userLeavingStatus, prevReport.statusNum, prevReport.parentReportID, prevReport.chatType]);
}, [
route,
report,
errors,
fetchReportIfNeeded,
prevReport.reportID,
prevUserLeavingStatus,
userLeavingStatus,
prevReport.statusNum,
prevReport.parentReportID,
prevReport.chatType,
prevReport,
]);

useEffect(() => {
if (!ReportUtils.isValidReportIDFromPath(reportID)) {
Expand Down Expand Up @@ -395,7 +416,15 @@ function ReportScreen({

// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowNotFoundPage = useMemo(
() => (!firstRenderRef.current && !report.reportID && !isOptimisticDelete && !reportMetadata.isLoadingInitialReportActions && !isLoading && !userLeavingStatus) || shouldHideReport,
() =>
(!wasReportAccessibleRef.current &&
!firstRenderRef.current &&
!report.reportID &&
!isOptimisticDelete &&
!reportMetadata.isLoadingInitialReportActions &&
!isLoading &&
!userLeavingStatus) ||
shouldHideReport,
[report, reportMetadata, isLoading, shouldHideReport, isOptimisticDelete, userLeavingStatus],
);

Expand Down

0 comments on commit 463ca55

Please sign in to comment.