From 1286f6deca3f5b1d8fa8074c71ad8b3155a79e08 Mon Sep 17 00:00:00 2001 From: dukenv0307 <dukenv0307@gmail.com> Date: Fri, 1 Mar 2024 08:44:01 +0700 Subject: [PATCH] fix delete comment issue --- src/libs/ReportActionsUtils.ts | 1 + src/libs/ReportUtils.ts | 3 +-- src/libs/actions/Report.ts | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 5c2a25e1d328..693c660880e2 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -502,6 +502,7 @@ function getLastVisibleMessage(reportID: string, actionsToMerge: OnyxCollection< } return { lastMessageText: messageText, + lastMessageHtml: message?.html, }; } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 92283e95aa81..9ecd556a0d1f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1805,7 +1805,6 @@ function buildOptimisticCancelPaymentReportAction(expenseReportID: string, amoun function getLastVisibleMessage(reportID: string | undefined, actionsToMerge: ReportActions = {}): LastVisibleMessage { const report = getReport(reportID); const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(reportID ?? '', actionsToMerge); - // For Chat Report with deleted parent actions, let us fetch the correct message if (ReportActionsUtils.isDeletedParentAction(lastVisibleAction) && !isEmptyObject(report) && isChatReport(report)) { const lastMessageText = getDeletedParentActionMessageForChatReport(lastVisibleAction); @@ -1813,7 +1812,7 @@ function getLastVisibleMessage(reportID: string | undefined, actionsToMerge: Rep lastMessageText, }; } - + // Fetch the last visible message for report represented by reportID and based on actions to merge. return ReportActionsUtils.getLastVisibleMessage(reportID ?? '', actionsToMerge); } diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 229da5756208..2f03055f610c 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1169,7 +1169,7 @@ function deleteReportComment(reportID: string, reportAction: ReportAction) { lastMessageText: '', lastVisibleActionCreated: '', }; - const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportUtils.getLastVisibleMessage(originalReportID, optimisticReportActions as ReportActions); + const {lastMessageText = '', lastMessageTranslationKey = '', lastMessageHtml = ''} = ReportUtils.getLastVisibleMessage(originalReportID, optimisticReportActions as ReportActions); if (lastMessageText || lastMessageTranslationKey) { const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(originalReportID, optimisticReportActions as ReportActions); const lastVisibleActionCreated = lastVisibleAction?.created; @@ -1179,6 +1179,7 @@ function deleteReportComment(reportID: string, reportAction: ReportAction) { lastMessageText, lastVisibleActionCreated, lastActorAccountID, + lastMessageHtml }; }