From afac89ec309687a8c562317de1327256aa0b710c Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Sat, 7 Oct 2023 01:04:23 +0700 Subject: [PATCH 1/5] fix: 28969 --- src/pages/home/ReportScreen.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 78f6edcf7dd3..faed80059507 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -157,6 +157,8 @@ function ReportScreen({ const prevUserLeavingStatus = usePrevious(userLeavingStatus); const [isBannerVisible, setIsBannerVisible] = useState(true); + const wasReportAccessibleRef = useRef(false); + const reportID = getReportID(route); const {addWorkspaceRoomOrChatPendingAction, addWorkspaceRoomOrChatErrors} = ReportUtils.getReportOfflinePendingActionAndErrors(report); const screenWrapperStyle = [styles.appContent, styles.flex1, {marginTop: viewportOffsetTop}]; @@ -179,6 +181,12 @@ function ReportScreen({ const isTopMostReportId = currentReportID === getReportID(route); const didSubscribeToReportLeavingEvents = useRef(false); + useEffect(() => { + if (report && report.reportID && !shouldHideReport) { + wasReportAccessibleRef.current = true; + } + }, [shouldHideReport, report]); + let headerView = ( (!firstRenderRef.current && !report.reportID && !isOptimisticDelete && !reportMetadata.isLoadingReportActions && !isLoading && !userLeavingStatus) || shouldHideReport, + () => (!wasReportAccessibleRef.current && !firstRenderRef.current && !report.reportID && !isOptimisticDelete && !reportMetadata.isLoadingReportActions && !isLoading && !userLeavingStatus) || shouldHideReport, [report, reportMetadata, isLoading, shouldHideReport, isOptimisticDelete, userLeavingStatus], ); From 8231d4f6c7c9b69a46425a7cdb08506bbe024810 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 6 Dec 2023 20:50:26 +0700 Subject: [PATCH 2/5] fix infinite loading when deleting money report --- src/pages/home/ReportScreen.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index c5f8e2b883dc..d8c8734bb362 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -186,10 +186,12 @@ function ReportScreen({ const isTopMostReportId = currentReportID === getReportID(route); const didSubscribeToReportLeavingEvents = useRef(false); + useEffect(() => { - if (report && report.reportID && !shouldHideReport) { - wasReportAccessibleRef.current = true; + if (!report || !report.reportID || shouldHideReport) { + return; } + wasReportAccessibleRef.current = true; }, [shouldHideReport, report]); const goBack = useCallback(() => { @@ -311,7 +313,6 @@ function ReportScreen({ const onyxReportID = report.reportID; const prevOnyxReportID = prevReport.reportID; const routeReportID = getReportID(route); - // Navigate to the Concierge chat if the room was removed from another device (e.g. user leaving a room or removed from a room) if ( // non-optimistic case @@ -321,7 +322,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) && _.isEqual(report, defaultProps.report)) ) { Navigation.dismissModal(); if (Navigation.getTopmostReportId() === prevOnyxReportID) { From b9d80d156a426170fa9dd9a99505b825c19b362d Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 14 Dec 2023 12:42:14 +0700 Subject: [PATCH 3/5] fix infinite loading in iou report --- src/pages/home/ReportScreen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 9d9330b9c720..71d16c118a7c 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -326,7 +326,7 @@ function ReportScreen({ !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))) || - (ReportUtils.isMoneyRequest(prevReport) && _.isEqual(report, defaultProps.report)) + ((ReportUtils.isMoneyRequest(prevReport.reportID) || ReportUtils.isMoneyRequestReport(prevReport.reportID)) && _.isEqual(report, defaultProps.report)) ) { Navigation.dismissModal(); if (Navigation.getTopmostReportId() === prevOnyxReportID) { From 4a4317e1b5f4759ac573efc8c35ce95ea186df96 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Thu, 14 Dec 2023 16:41:46 +0700 Subject: [PATCH 4/5] fix issue --- src/pages/home/ReportScreen.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 71d16c118a7c..8889a59f6ab2 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -316,6 +316,7 @@ function ReportScreen({ const onyxReportID = report.reportID; const prevOnyxReportID = prevReport.reportID; const routeReportID = getReportID(route); + // Navigate to the Concierge chat if the room was removed from another device (e.g. user leaving a room or removed from a room) if ( // non-optimistic case @@ -326,7 +327,7 @@ function ReportScreen({ !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))) || - ((ReportUtils.isMoneyRequest(prevReport.reportID) || ReportUtils.isMoneyRequestReport(prevReport.reportID)) && _.isEqual(report, defaultProps.report)) + ((ReportUtils.isMoneyRequest(prevReport) || ReportUtils.isMoneyRequestReport(prevReport)) && _.isEqual(report, defaultProps.report)) ) { Navigation.dismissModal(); if (Navigation.getTopmostReportId() === prevOnyxReportID) { @@ -351,7 +352,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)) { From 80196fcefc867fc6ded66c8c8b03101d4cba13c7 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 18 Dec 2023 14:22:59 +0700 Subject: [PATCH 5/5] check if report empty --- src/pages/home/ReportScreen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 3f7e2fdfaf74..1974296c82e1 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -350,7 +350,7 @@ function ReportScreen({ !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))) || - ((ReportUtils.isMoneyRequest(prevReport) || ReportUtils.isMoneyRequestReport(prevReport)) && _.isEqual(report, defaultProps.report)) + ((ReportUtils.isMoneyRequest(prevReport) || ReportUtils.isMoneyRequestReport(prevReport)) && _.isEmpty(report)) ) { Navigation.dismissModal(); if (Navigation.getTopmostReportId() === prevOnyxReportID) {