From 1367dc48bbfc81c726793d8775aa594202b8f1af Mon Sep 17 00:00:00 2001
From: Carlos Martins <cmartins@expensify.com>
Date: Thu, 27 Feb 2025 12:23:19 -0300
Subject: [PATCH 1/7] exclude only threads

---
 src/libs/OptionsListUtils.ts | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts
index a18300f593b8..4ddb22e91ac4 100644
--- a/src/libs/OptionsListUtils.ts
+++ b/src/libs/OptionsListUtils.ts
@@ -215,7 +215,7 @@ type GetOptionsConfig = {
     includeRecentReports?: boolean;
     includeSelectedOptions?: boolean;
     recentAttendees?: Attendee[];
-    excludeHiddenReports?: boolean;
+    excludeHiddenThreads?: boolean;
     canShowManagerMcTest?: boolean;
 } & GetValidReportsConfig;
 
@@ -1475,7 +1475,7 @@ function getValidOptions(
         selectedOptions = [],
         shouldSeparateSelfDMChat = false,
         shouldSeparateWorkspaceChat = false,
-        excludeHiddenReports = false,
+        excludeHiddenThreads = false,
         canShowManagerMcTest = false,
         ...config
     }: GetOptionsConfig = {},
@@ -1570,8 +1570,8 @@ function getValidOptions(
         }
     }
 
-    if (excludeHiddenReports) {
-        recentReportOptions = recentReportOptions.filter((option) => option.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN);
+    if (excludeHiddenThreads) {
+        recentReportOptions = recentReportOptions.filter((option) => !!option.parentReportActionID && option.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN);
     }
 
     return {
@@ -1604,7 +1604,7 @@ function getSearchOptions(options: OptionList, betas: Beta[] = [], isUsedInChatF
         includeTasks: true,
         includeSelfDM: true,
         shouldBoldTitleByDefault: !isUsedInChatFinder,
-        excludeHiddenReports: true,
+        excludeHiddenThreads: true,
     });
     const orderedOptions = orderOptions(optionList);
     Timing.end(CONST.TIMING.LOAD_SEARCH_OPTIONS);

From aef6609c31d32f9159d42dbb86f0f1b56baf5299 Mon Sep 17 00:00:00 2001
From: Carlos Martins <cmartins@expensify.com>
Date: Mon, 3 Mar 2025 17:27:57 -0300
Subject: [PATCH 2/7] fix logic and tests

---
 src/libs/OptionsListUtils.ts       | 2 +-
 tests/unit/OptionsListUtilsTest.ts | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts
index 16d4aaa2a3bf..f698e29094ba 100644
--- a/src/libs/OptionsListUtils.ts
+++ b/src/libs/OptionsListUtils.ts
@@ -1580,7 +1580,7 @@ function getValidOptions(
     }
 
     if (excludeHiddenThreads) {
-        recentReportOptions = recentReportOptions.filter((option) => !!option.parentReportActionID && option.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN);
+        recentReportOptions = recentReportOptions.filter((option) => (!option.parentReportActionID && !option.parentReportID) || option.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN);
     }
 
     return {
diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts
index 5a964cd7d6f0..61f339d54bea 100644
--- a/tests/unit/OptionsListUtilsTest.ts
+++ b/tests/unit/OptionsListUtilsTest.ts
@@ -195,6 +195,8 @@ describe('OptionsListUtils', () => {
             type: CONST.REPORT.TYPE.CHAT,
             policyID,
             policyName: POLICY.name,
+            parentReportActionID: '1',
+            parentReportID: '123',
         },
     };
 
@@ -547,7 +549,7 @@ describe('OptionsListUtils', () => {
         // Filtering of personalDetails that have reports is done in filterOptions
         expect(results.personalDetails.length).toBe(9);
 
-        // Then all of the reports should be shown including the archived rooms, except for the report with notificationPreferences hidden.
+        // Then all of the reports should be shown including the archived rooms, except for the thread report with notificationPreferences hidden.
         expect(results.recentReports.length).toBe(Object.values(OPTIONS.reports).length - 1);
     });
 

From 2d99d1a9dd3507b7316b6bf15619be7459389c3f Mon Sep 17 00:00:00 2001
From: Carlos Martins <cmartins@expensify.com>
Date: Mon, 3 Mar 2025 17:56:25 -0300
Subject: [PATCH 3/7] fix lint

---
 src/libs/OptionsListUtils.ts | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts
index f698e29094ba..5ab962d17b57 100644
--- a/src/libs/OptionsListUtils.ts
+++ b/src/libs/OptionsListUtils.ts
@@ -1580,7 +1580,9 @@ function getValidOptions(
     }
 
     if (excludeHiddenThreads) {
-        recentReportOptions = recentReportOptions.filter((option) => (!option.parentReportActionID && !option.parentReportID) || option.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN);
+        recentReportOptions = recentReportOptions.filter(
+            (option) => (!option.parentReportActionID && !option.parentReportID) || option.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
+        );
     }
 
     return {

From cf4debb1c0e47e2b6a3a43cd429533b1691ca58d Mon Sep 17 00:00:00 2001
From: Carlos Martins <cmartins@expensify.com>
Date: Mon, 3 Mar 2025 18:10:14 -0300
Subject: [PATCH 4/7] fix test

---
 tests/unit/OptionsListUtilsTest.ts | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts
index 61f339d54bea..1a09314bca57 100644
--- a/tests/unit/OptionsListUtilsTest.ts
+++ b/tests/unit/OptionsListUtilsTest.ts
@@ -195,7 +195,7 @@ describe('OptionsListUtils', () => {
             type: CONST.REPORT.TYPE.CHAT,
             policyID,
             policyName: POLICY.name,
-            parentReportActionID: '1',
+            parentReportActionID: '123',
             parentReportID: '123',
         },
     };
@@ -768,8 +768,8 @@ describe('OptionsListUtils', () => {
         // When we pass an empty search value
         let results = getShareDestinationOptions(filteredReports, OPTIONS.personalDetails, []);
 
-        // Then we should expect all the recent reports to show but exclude the archived rooms
-        expect(results.recentReports.length).toBe(Object.values(OPTIONS.reports).length - 1);
+        // Then we should expect all the recent reports to show but exclude the archived rooms and the hidden thread
+        expect(results.recentReports.length).toBe(Object.values(OPTIONS.reports).length - 2);
 
         // Filter current REPORTS_WITH_WORKSPACE_ROOMS as we do in the component, before getting share destination options
         const filteredReportsWithWorkspaceRooms = Object.values(OPTIONS_WITH_WORKSPACE_ROOM.reports).reduce<OptionList['reports']>((filtered, option) => {
@@ -784,8 +784,8 @@ describe('OptionsListUtils', () => {
         // When we also have a policy to return rooms in the results
         results = getShareDestinationOptions(filteredReportsWithWorkspaceRooms, OPTIONS.personalDetails, []);
         // Then we should expect the DMS, the group chats and the workspace room to show
-        // We should expect all the recent reports to show, excluding the archived rooms
-        expect(results.recentReports.length).toBe(Object.values(OPTIONS_WITH_WORKSPACE_ROOM.reports).length - 1);
+        // We should expect all the recent reports to show, excluding the archived rooms and the hidden thread
+        expect(results.recentReports.length).toBe(Object.values(OPTIONS_WITH_WORKSPACE_ROOM.reports).length - 2);
     });
 
     describe('getShareLogOptions', () => {
@@ -797,7 +797,7 @@ describe('OptionsListUtils', () => {
             const results = getShareLogOptions(OPTIONS, []);
 
             // Then the report with reportID of 10 should not be included on the list
-            expect(results.recentReports.length).toBe(10);
+            expect(results.recentReports.length).toBe(9);
             expect(results.recentReports.find((report) => report.reportID === '10')).toBeUndefined();
         });
     });

From 9e650de43abd80e48095a3cc179095ed85fe01f5 Mon Sep 17 00:00:00 2001
From: Carlos Martins <cmartins@expensify.com>
Date: Tue, 4 Mar 2025 13:54:51 -0300
Subject: [PATCH 5/7] fix tests

---
 tests/unit/OptionsListUtilsTest.ts | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts
index 1a09314bca57..5f99086aec56 100644
--- a/tests/unit/OptionsListUtilsTest.ts
+++ b/tests/unit/OptionsListUtilsTest.ts
@@ -179,9 +179,24 @@ describe('OptionsListUtils', () => {
             isOwnPolicyExpenseChat: true,
             type: CONST.REPORT.TYPE.CHAT,
         },
+        '11': {
+            lastReadTime: '2021-01-14 11:25:39.200',
+            lastVisibleActionCreated: '2022-11-22 03:26:02.001',
+            reportID: '11',
+            isPinned: false,
+            participants: {
+                10: {notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN},
+            },
+            reportName: '',
+            chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
+            isOwnPolicyExpenseChat: true,
+            type: CONST.REPORT.TYPE.CHAT,
+            policyID,
+            policyName: POLICY.name,
+        },
 
         // Thread report with notification preference = hidden
-        '11': {
+        '12': {
             lastReadTime: '2021-01-14 11:25:39.200',
             lastVisibleActionCreated: '2022-11-22 03:26:02.001',
             reportID: '11',
@@ -797,7 +812,7 @@ describe('OptionsListUtils', () => {
             const results = getShareLogOptions(OPTIONS, []);
 
             // Then the report with reportID of 10 should not be included on the list
-            expect(results.recentReports.length).toBe(9);
+            expect(results.recentReports.length).toBe(10);
             expect(results.recentReports.find((report) => report.reportID === '10')).toBeUndefined();
         });
     });
@@ -836,7 +851,7 @@ describe('OptionsListUtils', () => {
             const options = getSearchOptions(OPTIONS, [CONST.BETAS.ALL]);
             const filteredOptions = filterAndOrderOptions(options, '');
 
-            expect(filteredOptions.recentReports.length + filteredOptions.personalDetails.length).toBe(12);
+            expect(filteredOptions.recentReports.length + filteredOptions.personalDetails.length).toBe(13);
         });
 
         it('should return filtered options in correct order', () => {
@@ -925,7 +940,7 @@ describe('OptionsListUtils', () => {
             const options = getSearchOptions(OPTIONS);
             const filteredOptions = filterAndOrderOptions(options, searchText);
 
-            expect(filteredOptions.recentReports.length).toBe(2);
+            expect(filteredOptions.recentReports.length).toBe(3);
             expect(filteredOptions.recentReports.at(0)?.text).toBe('Mister Fantastic');
             expect(filteredOptions.recentReports.at(1)?.text).toBe('Mister Fantastic, Invisible Woman');
         });
@@ -1153,7 +1168,7 @@ describe('OptionsListUtils', () => {
             const options = getSearchOptions(OPTIONS);
             const filteredOptions = filterAndOrderOptions(options, 'fantastic');
 
-            expect(filteredOptions.recentReports.length).toBe(2);
+            expect(filteredOptions.recentReports.length).toBe(3);
             expect(filteredOptions.recentReports.at(0)?.text).toBe('Mister Fantastic');
             expect(filteredOptions.recentReports.at(1)?.text).toBe('Mister Fantastic, Invisible Woman');
 

From 9f12881eeeb727233aa9fb8b427aee8265e934c0 Mon Sep 17 00:00:00 2001
From: Carlos Martins <cmartins@expensify.com>
Date: Wed, 5 Mar 2025 16:07:21 -0300
Subject: [PATCH 6/7] fix bug

---
 src/libs/OptionsListUtils.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts
index 5ab962d17b57..102b31614d29 100644
--- a/src/libs/OptionsListUtils.ts
+++ b/src/libs/OptionsListUtils.ts
@@ -1581,7 +1581,7 @@ function getValidOptions(
 
     if (excludeHiddenThreads) {
         recentReportOptions = recentReportOptions.filter(
-            (option) => (!option.parentReportActionID && !option.parentReportID) || option.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
+            (option) => !option.isThread || option.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
         );
     }
 

From 3097f7abc9de4ecc55f4c0ffc7579799a569dc9b Mon Sep 17 00:00:00 2001
From: Carlos Martins <cmartins@expensify.com>
Date: Wed, 5 Mar 2025 16:15:23 -0300
Subject: [PATCH 7/7] fix lint

---
 src/libs/OptionsListUtils.ts | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts
index 102b31614d29..929ea5f7229a 100644
--- a/src/libs/OptionsListUtils.ts
+++ b/src/libs/OptionsListUtils.ts
@@ -1580,9 +1580,7 @@ function getValidOptions(
     }
 
     if (excludeHiddenThreads) {
-        recentReportOptions = recentReportOptions.filter(
-            (option) => !option.isThread || option.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
-        );
+        recentReportOptions = recentReportOptions.filter((option) => !option.isThread || option.notificationPreference !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN);
     }
 
     return {
