diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index de77e7f5243e..4ab84faad6e4 100644 --- a/src/libs/ReportActionsUtils.js +++ b/src/libs/ReportActionsUtils.js @@ -158,7 +158,7 @@ function getLastVisibleMessageText(reportID, actionsToMerge = {}) { const htmlText = lodashGet(lastVisibleAction, 'message[0].html', ''); const parser = new ExpensiMark(); const messageText = parser.htmlToText(htmlText); - return String(messageText).replace(CONST.REGEX.AFTER_FIRST_LINE_BREAK, '').substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH); + return String(messageText).replace(CONST.REGEX.AFTER_FIRST_LINE_BREAK, '').substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim(); } /** diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 18a479675110..dc295460175b 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -525,12 +525,12 @@ function canShowReportRecipientLocalTime(personalDetails, report) { } /** - * Trim the last message text to a fixed limit. + * Html decode, shorten last message text to fixed length and trim spaces. * @param {String} lastMessageText * @returns {String} */ function formatReportLastMessageText(lastMessageText) { - return String(lastMessageText).replace(CONST.REGEX.AFTER_FIRST_LINE_BREAK, '').substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH); + return Str.htmlDecode(String(lastMessageText)).replace(CONST.REGEX.AFTER_FIRST_LINE_BREAK, '').substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim(); } /** diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 26d9b9da7357..d881994302ab 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -218,7 +218,7 @@ function addActions(reportID, text = '', file) { const optimisticReport = { lastVisibleActionCreated: currentTime, - lastMessageText: Str.htmlDecode(lastCommentText), + lastMessageText: lastCommentText, lastActorEmail: currentUserEmail, lastReadTime: currentTime, }; @@ -979,7 +979,7 @@ function editReportComment(reportID, originalReportAction, textForNewComment) { const reportComment = parser.htmlToText(htmlForNewComment); const lastMessageText = ReportUtils.formatReportLastMessageText(reportComment); const optimisticReport = { - lastMessageText: Str.htmlDecode(lastMessageText), + lastMessageText, }; optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE,