From 362e25aac8ef834ac533024ce9cada1a5456f60b Mon Sep 17 00:00:00 2001
From: Jack Nam <jack@expensify.com>
Date: Sun, 14 May 2023 01:36:49 -0700
Subject: [PATCH 1/4] update isThread check and include task reports in LHN

---
 src/libs/ReportUtils.js               | 8 ++++++--
 src/libs/SidebarUtils.js              | 8 +++-----
 src/pages/home/report/ReportFooter.js | 2 +-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js
index bf891ec11ecf..3b5fc924a4c0 100644
--- a/src/libs/ReportUtils.js
+++ b/src/libs/ReportUtils.js
@@ -434,7 +434,7 @@ function isPolicyExpenseChatAdmin(report, policies) {
  * @returns {Boolean}
  */
 function isThread(report) {
-    return Boolean(report && report.parentReportID && report.parentReportActionID);
+    return Boolean(report && report.parentReportID && report.parentReportActionID && report.type === CONST.REPORT.TYPE.CHAT);
 }
 
 /**
@@ -1713,7 +1713,11 @@ function shouldReportBeInOptionList(report, reportIDFromRoute, isInGSDMode, curr
     // Exclude reports that have no data because there wouldn't be anything to show in the option item.
     // This can happen if data is currently loading from the server or a report is in various stages of being created.
     // This can also happen for anyone accessing a public room or archived room for which they don't have access to the underlying policy.
-    if (!report || !report.reportID || (_.isEmpty(report.participants) && !isThread(report) && !isPublicRoom(report) && !isArchivedRoom(report) && !isMoneyRequestReport(report))) {
+    if (
+        !report ||
+        !report.reportID ||
+        (_.isEmpty(report.participants) && !isThread(report) && !isPublicRoom(report) && !isArchivedRoom(report) && !isMoneyRequestReport(report) && !isTaskReport(report))
+    ) {
         return false;
     }
 
diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js
index ae28a75a5225..c2ffb5665b47 100644
--- a/src/libs/SidebarUtils.js
+++ b/src/libs/SidebarUtils.js
@@ -161,7 +161,8 @@ function getOrderedReportIDs(reportIDFromRoute) {
             return;
         }
 
-        if (ReportUtils.isTaskReport(report)) {
+        if (ReportUtils.isTaskReport(report) && report.stateNum !== CONST.REPORT.STATE.OPEN && report.statusNum !== CONST.REPORT.STATUS.OPEN) {
+            archivedReports.push(report);
             return;
         }
 
@@ -303,10 +304,8 @@ function getOptionData(reportID) {
         });
     }
 
-    if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread) && !result.isArchivedRoom) {
+    if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport) && !result.isArchivedRoom) {
         result.alternateText = lastMessageTextFromReport.length > 0 ? lastMessageText : Localize.translate(preferredLocale, 'report.noActivityYet');
-    } else if (result.isTaskReport) {
-        result.alternateText = Localize.translate(preferredLocale, 'newTaskPage.task');
     } else {
         if (!lastMessageText) {
             // Here we get the beginning of chat history message and append the display name for each user, adding pronouns if there are any.
@@ -349,7 +348,6 @@ function getOptionData(reportID) {
     result.icons = ReportUtils.getIcons(result.isTaskReport ? parentReport : report, personalDetails, policies, ReportUtils.getAvatar(personalDetail.avatar, personalDetail.login));
     result.searchText = OptionsListUtils.getSearchText(report, reportName, participantPersonalDetailList, result.isChatRoom || result.isPolicyExpenseChat);
     result.displayNamesWithTooltips = displayNamesWithTooltips;
-
     return result;
 }
 
diff --git a/src/pages/home/report/ReportFooter.js b/src/pages/home/report/ReportFooter.js
index 15b89cb45082..92811fa7b0fc 100644
--- a/src/pages/home/report/ReportFooter.js
+++ b/src/pages/home/report/ReportFooter.js
@@ -65,7 +65,7 @@ class ReportFooter extends React.Component {
 
     render() {
         const isArchivedRoom = ReportUtils.isArchivedRoom(this.props.report);
-        const hideComposer = isArchivedRoom || !_.isEmpty(this.props.errors) || ReportUtils.isTaskReport(this.props.report);
+        const hideComposer = isArchivedRoom || !_.isEmpty(this.props.errors);
 
         return (
             <>

From c56255c6c1ad1ca954a2f4a807d9a394750eff2d Mon Sep 17 00:00:00 2001
From: Jack Nam <jack@expensify.com>
Date: Mon, 15 May 2023 16:15:02 -0700
Subject: [PATCH 2/4] remove from share in and add to search

---
 src/components/ReportActionItem/IOUPreview.js | 2 +-
 src/libs/OptionsListUtils.js                  | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/components/ReportActionItem/IOUPreview.js b/src/components/ReportActionItem/IOUPreview.js
index ec74e82a22d8..a63aaca4ff88 100644
--- a/src/components/ReportActionItem/IOUPreview.js
+++ b/src/components/ReportActionItem/IOUPreview.js
@@ -148,7 +148,7 @@ const IOUPreview = (props) => {
     // If props.action is undefined then we are displaying within IOUDetailsModal and should use the full report amount
     const requestAmount = props.isIOUAction ? moneyRequestAction.total : ReportUtils.getMoneyRequestTotal(props.iouReport);
     const requestCurrency = props.isIOUAction ? moneyRequestAction.currency : props.iouReport.currency;
-    const requestComment = Str.htmlDecode(moneyRequestAction.comment).trim()
+    const requestComment = Str.htmlDecode(moneyRequestAction.comment).trim();
 
     const getSettledMessage = () => {
         switch (lodashGet(props.action, 'originalMessage.paymentType', '')) {
diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js
index e1ab2145189e..245210e3f51d 100644
--- a/src/libs/OptionsListUtils.js
+++ b/src/libs/OptionsListUtils.js
@@ -549,6 +549,7 @@ function getOptions(
         forcePolicyNamePreview = false,
         includeOwnedWorkspaceChats = false,
         includeThreads = false,
+        includeTasks = false,
     },
 ) {
     if (!isPersonalDetailsReady(personalDetails)) {
@@ -590,6 +591,7 @@ function getOptions(
 
         const isThread = ReportUtils.isThread(report);
         const isChatRoom = ReportUtils.isChatRoom(report);
+        const isTaskReport = ReportUtils.isTaskReport(report);
         const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report);
         const logins = report.participants || [];
 
@@ -601,6 +603,10 @@ function getOptions(
             return;
         }
 
+        if (isTaskReport && !includeTasks) {
+            return;
+        }
+
         // Save the report in the map if this is a single participant so we can associate the reportID with the
         // personal detail option later. Individuals should not be associated with single participant
         // policyExpenseChats or chatRooms since those are not people.
@@ -774,6 +780,7 @@ function getSearchOptions(reports, personalDetails, searchValue = '', betas) {
         includePersonalDetails: true,
         forcePolicyNamePreview: true,
         includeOwnedWorkspaceChats: true,
+        includeTasks: true,
     });
 }
 

From b0841813aa333a88f13ad72d72a2d352228903be Mon Sep 17 00:00:00 2001
From: Jack Nam <jack@expensify.com>
Date: Mon, 15 May 2023 16:34:58 -0700
Subject: [PATCH 3/4] prevent crashes

---
 src/libs/isReportMessageAttachment.js | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/libs/isReportMessageAttachment.js b/src/libs/isReportMessageAttachment.js
index e3553df5e1de..db7df0df6c89 100644
--- a/src/libs/isReportMessageAttachment.js
+++ b/src/libs/isReportMessageAttachment.js
@@ -8,6 +8,10 @@ import CONST from '../CONST';
  * @returns {Boolean}
  */
 export default function isReportMessageAttachment({text, html}) {
+    if (!text || !html) {
+        return false;
+    }
+
     const regex = new RegExp(` ${CONST.ATTACHMENT_SOURCE_ATTRIBUTE}="(.*)"`, 'i');
     return text === CONST.ATTACHMENT_MESSAGE_TEXT && !!html.match(regex);
 }

From c48f52e29f8c00c94906ee8923d39194bd2ea332 Mon Sep 17 00:00:00 2001
From: Jack Nam <jack@expensify.com>
Date: Mon, 15 May 2023 19:39:22 -0700
Subject: [PATCH 4/4] remove task handling

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

diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js
index 245210e3f51d..cb19a449dd11 100644
--- a/src/libs/OptionsListUtils.js
+++ b/src/libs/OptionsListUtils.js
@@ -410,6 +410,7 @@ function createOption(logins, personalDetails, report, reportActions = {}, {show
         result.isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report);
         result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report);
         result.isThread = ReportUtils.isThread(report);
+        result.isTaskReport = ReportUtils.isTaskReport(report);
         result.shouldShowSubscript = result.isPolicyExpenseChat && !report.isOwnPolicyExpenseChat && !result.isArchivedRoom;
         result.allReportErrors = getAllReportErrors(report, reportActions);
         result.brickRoadIndicator = !_.isEmpty(result.allReportErrors) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : '';
@@ -780,7 +781,6 @@ function getSearchOptions(reports, personalDetails, searchValue = '', betas) {
         includePersonalDetails: true,
         forcePolicyNamePreview: true,
         includeOwnedWorkspaceChats: true,
-        includeTasks: true,
     });
 }
 
