diff --git a/package-lock.json b/package-lock.json index 3b8a908ed689..a415564724c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,7 +50,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "2.0.84", + "expensify-common": "2.0.88", "expo": "51.0.31", "expo-av": "14.0.7", "expo-image": "1.12.15", @@ -24037,9 +24037,9 @@ } }, "node_modules/expensify-common": { - "version": "2.0.84", - "resolved": "https://registry.npmjs.org/expensify-common/-/expensify-common-2.0.84.tgz", - "integrity": "sha512-VistjMexRz/1u1IqjIZwGRE7aS6QOat7420Dualn+NaqMHGkfeeB4uUR3RQhCtlDbcwFBKTryIGgSrrC0N1YpA==", + "version": "2.0.88", + "resolved": "https://registry.npmjs.org/expensify-common/-/expensify-common-2.0.88.tgz", + "integrity": "sha512-4k6X6BekydYSRWkWRMB/Ts0W5Zx3BskEpLQEuxpq+cW9QIvTyFliho/dMLaXYOqS6nMQuzkjJYqfGPx9agVnOg==", "dependencies": { "awesome-phonenumber": "^5.4.0", "classnames": "2.5.0", diff --git a/package.json b/package.json index 49672cc191e7..792c8a0fc9ca 100644 --- a/package.json +++ b/package.json @@ -107,7 +107,7 @@ "date-fns-tz": "^2.0.0", "dom-serializer": "^0.2.2", "domhandler": "^4.3.0", - "expensify-common": "2.0.84", + "expensify-common": "2.0.88", "expo": "51.0.31", "expo-av": "14.0.7", "expo-image": "1.12.15", diff --git a/src/CONST.ts b/src/CONST.ts index 7d0cd3c4cf54..4ea00cf8201f 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1009,6 +1009,7 @@ const CONST = { MAX_PREVIEW_AVATARS: 4, MAX_ROOM_NAME_LENGTH: 99, LAST_MESSAGE_TEXT_MAX_LENGTH: 200, + MIN_LENGTH_LAST_MESSAGE_WITH_ELLIPSIS: 20, OWNER_EMAIL_FAKE: '__FAKE__', OWNER_ACCOUNT_ID_FAKE: 0, DEFAULT_REPORT_NAME: 'Chat Report', diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 61fe8387cce7..0c7b0c13b862 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -215,8 +215,11 @@ function isActionOfType( function getOriginalMessage(reportAction: OnyxInputOrEntry>): OriginalMessage | undefined { if (!Array.isArray(reportAction?.message)) { + // eslint-disable-next-line return reportAction?.message ?? reportAction?.originalMessage; } + + // eslint-disable-next-line return reportAction.originalMessage; } @@ -593,6 +596,7 @@ function isReportActionDeprecated(reportAction: OnyxEntry, key: st // HACK ALERT: We're temporarily filtering out any reportActions keyed by sequenceNumber // to prevent bugs during the migration from sequenceNumber -> reportActionID + // eslint-disable-next-line if (String(reportAction.sequenceNumber) === key) { Log.info('Front-end filtered out reportAction keyed by sequenceNumber!', false, reportAction); return true; @@ -753,6 +757,18 @@ function getLastVisibleAction(reportID: string, actionsToMerge: Record 0) || (trimmedMessage === '?\u2026' && lastMessageText.length > CONST.REPORT.MIN_LENGTH_LAST_MESSAGE_WITH_ELLIPSIS)) { + return ' '; + } + + return StringUtils.lineBreaksToSpaces(trimmedMessage).substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim(); +} + function getLastVisibleMessage( reportID: string, actionsToMerge: Record | null> = {}, @@ -777,7 +793,7 @@ function getLastVisibleMessage( let messageText = getReportActionMessageText(lastVisibleAction) ?? ''; if (messageText) { - messageText = StringUtils.lineBreaksToSpaces(String(messageText)).substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim(); + messageText = formatLastMessageText(messageText); } return { lastMessageText: messageText, @@ -1762,6 +1778,7 @@ function getCardIssuedMessage(reportAction: OnyxEntry, shouldRende export { doesReportHaveVisibleActions, extractLinksFromMessageHtml, + formatLastMessageText, getActionableMentionWhisperMessage, getAllReportActions, getCombinedReportActions, @@ -1784,6 +1801,7 @@ export { getNumberOfMoneyRequests, getOneTransactionThreadReportID, getOriginalMessage, + // eslint-disable-next-line getParentReportAction, getRemovedFromApprovalChainMessage, getReportAction, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 3cac7d09ad63..61efc161c738 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -83,7 +83,6 @@ import * as PolicyUtils from './PolicyUtils'; import type {LastVisibleMessage} from './ReportActionsUtils'; import * as ReportActionsUtils from './ReportActionsUtils'; import * as ReportConnection from './ReportConnection'; -import StringUtils from './StringUtils'; import * as TransactionUtils from './TransactionUtils'; import * as Url from './Url'; import type {AvatarSource} from './UserUtils'; @@ -1839,7 +1838,8 @@ function formatReportLastMessageText(lastMessageText: string, isModifiedExpenseM if (isModifiedExpenseMessage) { return String(lastMessageText).trim().replace(CONST.REGEX.LINE_BREAK, '').trim(); } - return StringUtils.lineBreaksToSpaces(String(lastMessageText).trim()).substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim(); + + return ReportActionsUtils.formatLastMessageText(lastMessageText); } /**