From c2613a7b32980a62495d809a6974e2426f293865 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 1 Mar 2024 07:25:24 +0700 Subject: [PATCH] fix last message text display --- src/libs/OptionsListUtils.ts | 10 ++++++++-- src/libs/ReportUtils.ts | 8 +++++++- src/libs/actions/Report.ts | 5 ++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 9121eebb3367..3f8176a3f6f5 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1,4 +1,5 @@ /* eslint-disable no-continue */ +import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import Str from 'expensify-common/lib/str'; // eslint-disable-next-line you-dont-need-lodash-underscore/get import lodashGet from 'lodash/get'; @@ -585,8 +586,13 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails } else if (ReportActionUtils.isCreatedTaskReportAction(lastReportAction)) { lastMessageTextFromReport = TaskUtils.getTaskCreatedMessage(lastReportAction); } - - return lastMessageTextFromReport || (report?.lastMessageText ?? ''); + const parser = new ExpensiMark(); + return ( + lastMessageTextFromReport || + (lastActionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT + ? ReportUtils.formatReportLastMessageText(parser.htmlToText(report?.lastMessageHtml ?? ''), false, true) + : report?.lastMessageText ?? '') + ); } /** diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ea0eba523092..92283e95aa81 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1377,10 +1377,16 @@ function canShowReportRecipientLocalTime(personalDetails: OnyxCollection = { lastVisibleActionCreated: currentTime, lastMessageTranslationKey: lastComment?.translationKey ?? '', - lastMessageText: lastCommentText, - lastMessageHtml: lastCommentText, + lastMessageText: text, + lastMessageHtml: text, lastActorAccountID: currentUserAccountID, lastReadTime: currentTime, };