From 93e5812d4a4414e7879b6bcc63bce621542bd33a Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 24 Jul 2023 11:48:02 -1000 Subject: [PATCH 1/4] Fix bugs surrounding report name when deleting first thread comment --- src/libs/actions/Report.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 7c482339da47..1968ba3ba1ec 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -897,7 +897,7 @@ function deleteReportComment(reportID, reportAction) { lastMessageText: '', lastVisibleActionCreated: '', }; - if (reportAction.reportActionID && reportAction.childVisibleActionCount > 0) { + if (reportAction.reportActionID && reportAction.childVisibleActionCount === 0) { optimisticReport = { lastMessageTranslationKey: '', lastMessageText: '', @@ -963,6 +963,16 @@ function deleteReportComment(reportID, reportAction) { optimisticData.push(optimisticParentReportData); } + // If the reportID doesn't equal the originalReportID then this is the first comment on a thread report and we need to trigger + // some sort of update to let the LHN know that the parentReportAction is now deleted. + if (reportID !== originalReportID) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: {isParentReportActionDeleted: true}, + }); + } + const parameters = { reportID: originalReportID, reportActionID, From f59e58e560bfcb02a4f48e8be6bdffe74bcdcfdd Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 24 Jul 2023 12:24:12 -1000 Subject: [PATCH 2/4] Use isThreadFirstChat --- src/libs/actions/Report.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 1968ba3ba1ec..a5f5f534e53b 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -965,10 +965,13 @@ function deleteReportComment(reportID, reportAction) { // If the reportID doesn't equal the originalReportID then this is the first comment on a thread report and we need to trigger // some sort of update to let the LHN know that the parentReportAction is now deleted. - if (reportID !== originalReportID) { + if (ReportUtils.isThreadFirstChat(reportAction, reportID)) { optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + + // This may appear to be unused, but we don't use this field for anything other than to trigger an + // update to the LHN that the report action we are deleting is the first message of a thread. value: {isParentReportActionDeleted: true}, }); } From f841af323eba016152abef0c85797ba101f5a57f Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 24 Jul 2023 12:29:33 -1000 Subject: [PATCH 3/4] Remove check for reportAction.reportActionID --- src/libs/actions/Report.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index a5f5f534e53b..ab2e74efd927 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -897,7 +897,7 @@ function deleteReportComment(reportID, reportAction) { lastMessageText: '', lastVisibleActionCreated: '', }; - if (reportAction.reportActionID && reportAction.childVisibleActionCount === 0) { + if (reportAction.childVisibleActionCount === 0) { optimisticReport = { lastMessageTranslationKey: '', lastMessageText: '', From e99d99a9055315dab58ffb131545b81f56230347 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 24 Jul 2023 12:34:22 -1000 Subject: [PATCH 4/4] Improve comments and naming --- src/libs/actions/Report.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index ab2e74efd927..1b535f72fca9 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -963,16 +963,13 @@ function deleteReportComment(reportID, reportAction) { optimisticData.push(optimisticParentReportData); } - // If the reportID doesn't equal the originalReportID then this is the first comment on a thread report and we need to trigger - // some sort of update to let the LHN know that the parentReportAction is now deleted. + // Check to see if the report action we are deleting is the first comment on a thread report. In this case, we need to trigger + // an update to let the LHN know that the parentReportAction is now deleted. if (ReportUtils.isThreadFirstChat(reportAction, reportID)) { optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, - - // This may appear to be unused, but we don't use this field for anything other than to trigger an - // update to the LHN that the report action we are deleting is the first message of a thread. - value: {isParentReportActionDeleted: true}, + value: {updateReportInLHN: true}, }); }