Skip to content

Commit

Permalink
Merge pull request #23514 from Expensify/marcaaron-fixThreadReportName
Browse files Browse the repository at this point in the history
Fix bugs surrounding report name when deleting first thread comment
  • Loading branch information
marcaaron authored Jul 24, 2023
2 parents e6daea8 + e99d99a commit fbfabee
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ function deleteReportComment(reportID, reportAction) {
lastMessageText: '',
lastVisibleActionCreated: '',
};
if (reportAction.reportActionID && reportAction.childVisibleActionCount > 0) {
if (reportAction.childVisibleActionCount === 0) {
optimisticReport = {
lastMessageTranslationKey: '',
lastMessageText: '',
Expand Down Expand Up @@ -963,6 +963,16 @@ function deleteReportComment(reportID, reportAction) {
optimisticData.push(optimisticParentReportData);
}

// 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}`,
value: {updateReportInLHN: true},
});
}

const parameters = {
reportID: originalReportID,
reportActionID,
Expand Down

0 comments on commit fbfabee

Please sign in to comment.