From bdeb00222dc9090d7718a9c0e7d6412392cb4f21 Mon Sep 17 00:00:00 2001 From: Nabi Ebrahimi Date: Sun, 2 Nov 2025 12:00:14 +0430 Subject: [PATCH 1/3] Fix infinite loading on member's side when removed from workspace chat --- src/pages/home/ReportScreen.tsx | 42 ++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 9aaa475ea4ff..092d25bc67cd 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -1,5 +1,5 @@ import {PortalHost} from '@gorhom/portal'; -import {useIsFocused} from '@react-navigation/native'; +import {useFocusEffect, useIsFocused} from '@react-navigation/native'; import {accountIDSelector} from '@selectors/Session'; import {deepEqual} from 'fast-equals'; import React, {memo, useCallback, useEffect, useMemo, useRef, useState} from 'react'; @@ -349,6 +349,25 @@ function ReportScreen({route, navigation}: ReportScreenProps) { const newTransactions = useNewTransactions(reportMetadata?.hasOnceLoadedReportActions, reportTransactions); + const reportIdRef = useRef<{onyxReportId: string | undefined; routeReportId: string | undefined}>({onyxReportId: undefined, routeReportId: undefined}); + + const redirectBackOnDeletedReport = useCallback(() => { + if (!reportIdRef.current.onyxReportId) { + reportIdRef.current.onyxReportId = reportOnyx?.reportID; + reportIdRef.current.routeReportId = reportIDFromRoute; + } else { + if (reportOnyx?.reportID) { + return; + } + + if (reportIdRef.current.routeReportId === reportIDFromRoute) { + Navigation.goBack(route.params.backTo ?? undefined); + } + } + }, [reportOnyx?.reportID, route.params.backTo, reportIDFromRoute]); + + useFocusEffect(redirectBackOnDeletedReport); + useEffect(() => { if (!prevIsFocused || isFocused) { return; @@ -491,7 +510,15 @@ function ReportScreen({route, navigation}: ReportScreenProps) { } // eslint-disable-next-line react-compiler/react-compiler - if (!wasReportAccessibleRef.current && !firstRenderRef.current && !reportID && !isOptimisticDelete && !reportMetadata?.isLoadingInitialReportActions && !userLeavingStatus) { + if ( + !wasReportAccessibleRef.current && + !firstRenderRef.current && + !reportID && + !reportIdRef?.current && + !isOptimisticDelete && + !reportMetadata?.isLoadingInitialReportActions && + !userLeavingStatus + ) { // eslint-disable-next-line react-compiler/react-compiler return true; } @@ -499,7 +526,16 @@ function ReportScreen({route, navigation}: ReportScreenProps) { return !!currentReportIDFormRoute && !isValidReportIDFromPath(currentReportIDFormRoute); }, // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps - [firstRender, shouldShowNotFoundLinkedAction, reportID, isOptimisticDelete, reportMetadata?.isLoadingInitialReportActions, userLeavingStatus, currentReportIDFormRoute], + [ + firstRender, + shouldShowNotFoundLinkedAction, + reportID, + isOptimisticDelete, + reportMetadata?.isLoadingInitialReportActions, + userLeavingStatus, + currentReportIDFormRoute, + reportIdRef?.current, + ], ); const createOneTransactionThreadReport = useCallback(() => { From e2fc3f1a17aa7690923d84510e62f51dff048abe Mon Sep 17 00:00:00 2001 From: Nabi Ebrahimi Date: Wed, 10 Dec 2025 22:28:42 +0430 Subject: [PATCH 2/3] check only the property existence other than the whole object for reportIdRef --- src/pages/home/ReportScreen.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 243f54abbd2d..a502fff74247 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -519,7 +519,7 @@ function ReportScreen({route, navigation}: ReportScreenProps) { !wasReportAccessibleRef.current && !firstRenderRef.current && !reportID && - !reportIdRef?.current && + !reportIdRef?.current.onyxReportId && !isOptimisticDelete && !reportMetadata?.isLoadingInitialReportActions && !userLeavingStatus @@ -539,7 +539,7 @@ function ReportScreen({route, navigation}: ReportScreenProps) { reportMetadata?.isLoadingInitialReportActions, userLeavingStatus, currentReportIDFormRoute, - reportIdRef?.current, + reportIdRef?.current.onyxReportId, ], ); From 8e51afc8085f5bee6aecbce3d98c3722a63b66a4 Mon Sep 17 00:00:00 2001 From: Nabi Ebrahimi Date: Mon, 12 Jan 2026 14:45:32 +0430 Subject: [PATCH 3/3] removed unused code block --- src/pages/home/ReportScreen.tsx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index cf3160d8c02b..b8e92aca41fd 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -80,7 +80,6 @@ import { isInvoiceReport, isMoneyRequest, isMoneyRequestReport, - isMoneyRequestReportPendingDeletion, isOneTransactionThread, isPolicyExpenseChat, isReportTransactionThread, @@ -783,13 +782,6 @@ function ReportScreen({route, navigation, isInSidePanel = false}: ReportScreenPr }); } if (prevReport?.parentReportID) { - // Prevent navigation to the IOU/Expense Report if it is pending deletion. - if (isMoneyRequestReportPendingDeletion(prevReport.parentReportID)) { - return; - } - Navigation.isNavigationReady().then(() => { - Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(prevReport.parentReportID)); - }); return; }