diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index 923337ba9ada..7d281753e38b 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -225,7 +225,7 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti numberOfLines={1} accessibilityLabel={translate('accessibilityHints.lastChatMessagePreview')} > - {optionItem.alternateText} + {`${optionItem.alternateText}\u200B`} ) : null} 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/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 ea0eba523092..8f6c20436030 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, }; @@ -1170,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; @@ -1180,6 +1179,7 @@ function deleteReportComment(reportID: string, reportAction: ReportAction) { lastMessageText, lastVisibleActionCreated, lastActorAccountID, + lastMessageHtml, }; } diff --git a/tests/ui/UnreadIndicatorsTest.js b/tests/ui/UnreadIndicatorsTest.js index 6051f04f570e..3da4587c55b1 100644 --- a/tests/ui/UnreadIndicatorsTest.js +++ b/tests/ui/UnreadIndicatorsTest.js @@ -618,7 +618,7 @@ describe('Unread Indicators', () => { const hintText = Localize.translateLocal('accessibilityHints.lastChatMessagePreview'); const alternateText = screen.queryAllByLabelText(hintText); expect(alternateText).toHaveLength(1); - expect(alternateText[0].props.children).toBe('Current User Comment 1'); + expect(alternateText[0].props.children).toBe('Current User Comment 1\u200B'); Report.deleteReportComment(REPORT_ID, lastReportAction); return waitForBatchedUpdates(); @@ -627,7 +627,7 @@ describe('Unread Indicators', () => { const hintText = Localize.translateLocal('accessibilityHints.lastChatMessagePreview'); const alternateText = screen.queryAllByLabelText(hintText); expect(alternateText).toHaveLength(1); - expect(alternateText[0].props.children).toBe('Comment 9'); + expect(alternateText[0].props.children).toBe('Comment 9\u200B'); }) ); });