From a296f013b5dd2cce5e4d8d1f03c5c3b931d65360 Mon Sep 17 00:00:00 2001
From: nkdengineer <161821005+nkdengineer@users.noreply.github.com>
Date: Fri, 21 Nov 2025 22:26:37 +0700
Subject: [PATCH 1/4] Revert "[CP staging] Revert "fix: Two greyed-out RBRs in
 Inbox""

---
 src/pages/home/ReportScreen.tsx | 29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx
index 4c2d60d41ea3..037ddf20ce81 100644
--- a/src/pages/home/ReportScreen.tsx
+++ b/src/pages/home/ReportScreen.tsx
@@ -529,12 +529,6 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
             return;
         }
 
-        // If there is one transaction thread that has not yet been created, we should create it.
-        if (transactionThreadReportID === CONST.FAKE_REPORT_ID && !transactionThreadReport) {
-            createOneTransactionThreadReport();
-            return;
-        }
-
         // When a user goes through onboarding for the first time, various tasks are created for chatting with Concierge.
         // If this function is called too early (while the application is still loading), we will not have information about policies,
         // which means we will not be able to obtain the correct link for one of the tasks.
@@ -550,20 +544,7 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
         }
 
         openReport(reportIDFromRoute, reportActionIDFromRoute);
-    }, [
-        reportMetadata.isOptimisticReport,
-        report,
-        isOffline,
-        transactionThreadReportID,
-        transactionThreadReport,
-        reportIDFromRoute,
-        reportActionIDFromRoute,
-        createOneTransactionThreadReport,
-        isLoadingApp,
-        introSelected,
-        isOnboardingCompleted,
-        isInviteOnboardingComplete,
-    ]);
+    }, [reportMetadata.isOptimisticReport, report, isOffline, isLoadingApp, introSelected, isOnboardingCompleted, isInviteOnboardingComplete, reportIDFromRoute, reportActionIDFromRoute]);
 
     useEffect(() => {
         if (!isAnonymousUser) {
@@ -572,6 +553,14 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
         prevIsAnonymousUser.current = true;
     }, [isAnonymousUser]);
 
+    useEffect(() => {
+        if (transactionThreadReportID !== CONST.FAKE_REPORT_ID || transactionThreadReportID || !reportMetadata.hasOnceLoadedReportActions) {
+            return;
+        }
+
+        createOneTransactionThreadReport();
+    }, [reportMetadata.hasOnceLoadedReportActions, transactionThreadReportID, createOneTransactionThreadReport]);
+
     useEffect(() => {
         if (isLoadingReportData || !prevIsLoadingReportData || !prevIsAnonymousUser.current || isAnonymousUser) {
             return;

From 85c9483e8a6bb6d84c90fd081d453f06b5350d55 Mon Sep 17 00:00:00 2001
From: nkdengineer <nkdengineer@outlook.com>
Date: Sun, 23 Nov 2025 22:22:24 +0700
Subject: [PATCH 2/4] fix report doesn't load

---
 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 5ea83eb900f9..896f12d10eb5 100644
--- a/src/pages/home/ReportScreen.tsx
+++ b/src/pages/home/ReportScreen.tsx
@@ -549,12 +549,12 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
     }, [isAnonymousUser]);
 
     useEffect(() => {
-        if (transactionThreadReportID !== CONST.FAKE_REPORT_ID || transactionThreadReportID || !reportMetadata.hasOnceLoadedReportActions) {
+        if (transactionThreadReportID !== CONST.FAKE_REPORT_ID || transactionThreadReport?.reportID || (!reportMetadata.hasOnceLoadedReportActions && !reportMetadata?.isOptimisticReport)) {
             return;
         }
 
         createOneTransactionThreadReport();
-    }, [reportMetadata.hasOnceLoadedReportActions, transactionThreadReportID, createOneTransactionThreadReport]);
+    }, [reportMetadata.hasOnceLoadedReportActions, reportMetadata?.isOptimisticReport, transactionThreadReport?.reportID, createOneTransactionThreadReport, transactionThreadReportID]);
 
     useEffect(() => {
         if (isLoadingReportData || !prevIsLoadingReportData || !prevIsAnonymousUser.current || isAnonymousUser) {

From 4333d944e4def2208169962144fa81165dab34f6 Mon Sep 17 00:00:00 2001
From: nkdengineer <nkdengineer@outlook.com>
Date: Tue, 2 Dec 2025 17:58:30 +0700
Subject: [PATCH 3/4] create a ref to prevent calling twice

---
 src/pages/home/ReportScreen.tsx | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx
index c0b0e175d6b4..46558da2fe4b 100644
--- a/src/pages/home/ReportScreen.tsx
+++ b/src/pages/home/ReportScreen.tsx
@@ -163,6 +163,7 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
     const [firstRender, setFirstRender] = useState(true);
     const isSkippingOpenReport = useRef(false);
     const flatListRef = useRef<FlatList>(null);
+    const createOneTransactionThreadReportRef = useRef<() => void>(() => {});
     const {isBetaEnabled} = usePermissions();
     const {isOffline} = useNetwork();
     const {shouldUseNarrowLayout, isInNarrowPaneModal} = useResponsiveLayout();
@@ -542,6 +543,10 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
         openReport(reportIDFromRoute, reportActionIDFromRoute);
     }, [reportMetadata.isOptimisticReport, report, isOffline, isLoadingApp, introSelected, isOnboardingCompleted, isInviteOnboardingComplete, reportIDFromRoute, reportActionIDFromRoute]);
 
+    useEffect(() => {
+        createOneTransactionThreadReportRef.current = createOneTransactionThreadReport;
+    }, [createOneTransactionThreadReport]);
+
     useEffect(() => {
         if (!isAnonymousUser) {
             return;
@@ -554,8 +559,8 @@ function ReportScreen({route, navigation}: ReportScreenProps) {
             return;
         }
 
-        createOneTransactionThreadReport();
-    }, [reportMetadata.hasOnceLoadedReportActions, reportMetadata?.isOptimisticReport, transactionThreadReport?.reportID, createOneTransactionThreadReport, transactionThreadReportID]);
+        createOneTransactionThreadReportRef.current();
+    }, [reportMetadata.hasOnceLoadedReportActions, reportMetadata?.isOptimisticReport, transactionThreadReport?.reportID, transactionThreadReportID]);
 
     useEffect(() => {
         if (isLoadingReportData || !prevIsLoadingReportData || !prevIsAnonymousUser.current || isAnonymousUser) {

From 5385e9f2fdfeee21b2d224c5e69c13fc17cdc931 Mon Sep 17 00:00:00 2001
From: nkdengineer <nkdengineer@outlook.com>
Date: Sun, 15 Feb 2026 23:22:07 +0700
Subject: [PATCH 4/4] remove unnecessary ref

---
 src/pages/inbox/ReportScreen.tsx | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/pages/inbox/ReportScreen.tsx b/src/pages/inbox/ReportScreen.tsx
index 08154aabcbb2..90b51c12d18b 100644
--- a/src/pages/inbox/ReportScreen.tsx
+++ b/src/pages/inbox/ReportScreen.tsx
@@ -168,7 +168,6 @@ function ReportScreen({route, navigation, isInSidePanel = false}: ReportScreenPr
     const [firstRender, setFirstRender] = useState(true);
     const isSkippingOpenReport = useRef(false);
     const flatListRef = useRef<FlatList>(null);
-    const createOneTransactionThreadReportRef = useRef<() => void>(() => {});
     const hasCreatedLegacyThreadRef = useRef(false);
     const {isBetaEnabled} = usePermissions();
     const {isOffline} = useNetwork();
@@ -581,10 +580,6 @@ function ReportScreen({route, navigation, isInSidePanel = false}: ReportScreenPr
         openReport(reportIDFromRoute, introSelected, reportActionIDFromRoute);
     }, [reportMetadata.isOptimisticReport, report, isOffline, isLoadingApp, introSelected, isOnboardingCompleted, isInviteOnboardingComplete, reportIDFromRoute, reportActionIDFromRoute]);
 
-    useEffect(() => {
-        createOneTransactionThreadReportRef.current = createOneTransactionThreadReport;
-    }, [createOneTransactionThreadReport]);
-
     useEffect(() => {
         if (!isAnonymousUser) {
             return;
@@ -597,7 +592,8 @@ function ReportScreen({route, navigation, isInSidePanel = false}: ReportScreenPr
             return;
         }
 
-        createOneTransactionThreadReportRef.current();
+        createOneTransactionThreadReport();
+        // eslint-disable-next-line react-hooks/exhaustive-deps -- we don't want to run this useEffect when createOneTransactionThreadReport changes
     }, [reportMetadata.hasOnceLoadedReportActions, reportMetadata?.isOptimisticReport, transactionThreadReport?.reportID, transactionThreadReportID]);
 
     useEffect(() => {
