diff --git a/src/libs/DebugUtils.ts b/src/libs/DebugUtils.ts index cfc56559ed35..45ee00ac7823 100644 --- a/src/libs/DebugUtils.ts +++ b/src/libs/DebugUtils.ts @@ -460,7 +460,6 @@ function validateReportDraftProperty(key: keyof Report, value: string) { case 'reportID': case 'chatReportID': case 'type': - case 'lastMessageTranslationKey': case 'parentReportID': case 'parentReportActionID': case 'lastVisibleActionLastModified': @@ -600,7 +599,6 @@ function validateReportDraftProperty(key: keyof Report, value: string) { writeCapability: CONST.RED_BRICK_ROAD_PENDING_ACTION, visibility: CONST.RED_BRICK_ROAD_PENDING_ACTION, invoiceReceiver: CONST.RED_BRICK_ROAD_PENDING_ACTION, - lastMessageTranslationKey: CONST.RED_BRICK_ROAD_PENDING_ACTION, parentReportID: CONST.RED_BRICK_ROAD_PENDING_ACTION, parentReportActionID: CONST.RED_BRICK_ROAD_PENDING_ACTION, managerID: CONST.RED_BRICK_ROAD_PENDING_ACTION, @@ -1369,7 +1367,7 @@ function getReasonAndReportActionForRBRInLHNRow(report: Report, reportActions: O } function getTransactionID(report: OnyxEntry, reportActions: OnyxEntry) { - const transactionID = TransactionUtils.getTransactionID(report?.reportID ?? '-1'); + const transactionID = TransactionUtils.getTransactionID(report?.reportID); return Number(transactionID) > 0 ? transactionID diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 16d5bb03860c..5072830d1b8f 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -7,7 +7,6 @@ import type {SetNonNullable} from 'type-fest'; import {FallbackAvatar} from '@components/Icon/Expensicons'; import type {IOUAction} from '@src/CONST'; import CONST from '@src/CONST'; -import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import type { Beta, @@ -550,9 +549,8 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails lastMessageTextFromReport = ReportUtils.getDeletedParentActionMessageForChatReport(lastReportAction); } else if (ReportActionUtils.isPendingRemove(lastReportAction) && ReportActionUtils.isThreadParentMessage(lastReportAction, report?.reportID ?? '-1')) { lastMessageTextFromReport = Localize.translateLocal('parentReportAction.hiddenMessage'); - } else if (ReportUtils.isReportMessageAttachment({text: report?.lastMessageText ?? '-1', html: report?.lastMessageHtml, translationKey: report?.lastMessageTranslationKey, type: ''})) { - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - lastMessageTextFromReport = `[${Localize.translateLocal((report?.lastMessageTranslationKey || 'common.attachment') as TranslationPaths)}]`; + } else if (ReportUtils.isReportMessageAttachment({text: report?.lastMessageText ?? '-1', html: report?.lastMessageHtml, type: ''})) { + lastMessageTextFromReport = `[${Localize.translateLocal('common.attachment')}]`; } else if (ReportActionUtils.isModifiedExpenseAction(lastReportAction)) { const properSchemaForModifiedExpenseMessage = ModifiedExpenseMessage.getForReportAction(report?.reportID, lastReportAction); lastMessageTextFromReport = ReportUtils.formatReportLastMessageText(properSchemaForModifiedExpenseMessage, true); diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 455a125ad0c3..6431deb6d75b 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -33,7 +33,6 @@ import StringUtils from './StringUtils'; import * as TransactionUtils from './TransactionUtils'; type LastVisibleMessage = { - lastMessageTranslationKey?: string; lastMessageText: string; lastMessageHtml?: string; }; @@ -812,7 +811,6 @@ function getLastVisibleMessage( if (message && isReportMessageAttachment(message)) { return { - lastMessageTranslationKey: CONST.TRANSLATION_KEYS.ATTACHMENT, lastMessageText: CONST.ATTACHMENT_MESSAGE_TEXT, lastMessageHtml: CONST.TRANSLATION_KEYS.ATTACHMENT, }; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index c20ec7386b0a..7e0f983b3e9e 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -314,7 +314,6 @@ type OptimisticChatReport = Pick< | 'isOwnPolicyExpenseChat' | 'isPinned' | 'lastActorAccountID' - | 'lastMessageTranslationKey' | 'lastMessageHtml' | 'lastMessageText' | 'lastReadTime' @@ -5506,7 +5505,6 @@ function buildOptimisticChatReport( isOwnPolicyExpenseChat, isPinned: isNewlyCreatedWorkspaceChat, lastActorAccountID: 0, - lastMessageTranslationKey: '', lastMessageHtml: '', lastMessageText: undefined, lastReadTime: currentTime, @@ -6301,12 +6299,12 @@ function isEmptyReport(report: OnyxEntry): boolean { return true; } - if (report.lastMessageText ?? report.lastMessageTranslationKey) { + if (report.lastMessageText) { return false; } const lastVisibleMessage = getLastVisibleMessage(report.reportID); - return !lastVisibleMessage.lastMessageText && !lastVisibleMessage.lastMessageTranslationKey; + return !lastVisibleMessage.lastMessageText; } function isUnread(report: OnyxEntry): boolean { @@ -8421,20 +8419,18 @@ function findPolicyExpenseChatByPolicyID(policyID: string): OnyxEntry { */ function getReportLastMessage(reportID: string, actionsToMerge?: ReportActions) { let result: Partial = { - lastMessageTranslationKey: '', lastMessageText: '', lastVisibleActionCreated: '', }; - const {lastMessageText = '', lastMessageTranslationKey = ''} = getLastVisibleMessage(reportID, actionsToMerge); + const {lastMessageText = ''} = getLastVisibleMessage(reportID, actionsToMerge); - if (lastMessageText || lastMessageTranslationKey) { + if (lastMessageText) { const report = getReport(reportID); const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(reportID, canUserPerformWriteAction(report), actionsToMerge); const lastVisibleActionCreated = lastVisibleAction?.created; const lastActorAccountID = lastVisibleAction?.actorAccountID; result = { - lastMessageTranslationKey, lastMessageText, lastVisibleActionCreated, lastActorAccountID, diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts index 6643cd721d45..8bc1dd7356cb 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -1210,7 +1210,11 @@ function compareDuplicateTransactionFields( return {keep, change}; } -function getTransactionID(threadReportID: string): string | undefined { +function getTransactionID(threadReportID: string | undefined): string | undefined { + if (!threadReportID) { + return; + } + const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${threadReportID}`]; const parentReportAction = ReportUtils.isThread(report) ? ReportActionsUtils.getReportAction(report.parentReportID, report.parentReportActionID) : undefined; const IOUTransactionID = ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction)?.IOUTransactionID : undefined; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index c8d6fb36f60d..f2e738790fa6 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -713,7 +713,6 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR value: { ...chat.report, lastReadTime: DateUtils.getDBTime(), - lastMessageTranslationKey: '', iouReportID: iou.report.reportID, ...outstandingChildRequest, ...(isNewChatReport ? {pendingFields: {createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}} : {}), @@ -1185,7 +1184,6 @@ function buildOnyxDataForInvoice( value: { ...chatReport, lastReadTime: DateUtils.getDBTime(), - lastMessageTranslationKey: '', iouReportID: iouReport.reportID, ...(isNewChatReport ? {pendingFields: {createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}} : {}), }, diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index ab924906352e..5d390221822b 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -537,7 +537,6 @@ function addActions(reportID: string, text = '', file?: FileObject) { const optimisticReport: Partial = { lastVisibleActionCreated: lastAction?.created, - lastMessageTranslationKey: lastComment?.translationKey ?? '', lastMessageText: lastCommentText, lastMessageHtml: lastCommentText, lastActorAccountID: currentUserAccountID, @@ -605,17 +604,15 @@ function addActions(reportID: string, text = '', file?: FileObject) { ]; let failureReport: Partial = { - lastMessageTranslationKey: '', lastMessageText: '', lastVisibleActionCreated: '', }; - const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportActionsUtils.getLastVisibleMessage(reportID); - if (lastMessageText || lastMessageTranslationKey) { + const {lastMessageText = ''} = ReportActionsUtils.getLastVisibleMessage(reportID); + if (lastMessageText) { const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(reportID); const lastVisibleActionCreated = lastVisibleAction?.created; const lastActorAccountID = lastVisibleAction?.actorAccountID; failureReport = { - lastMessageTranslationKey, lastMessageText, lastVisibleActionCreated, lastActorAccountID, @@ -1555,19 +1552,17 @@ function deleteReportComment(reportID: string, reportAction: ReportAction) { // If we are deleting the last visible message, let's find the previous visible one (or set an empty one if there are none) and update the lastMessageText in the LHN. // Similarly, if we are deleting the last read comment we will want to update the lastVisibleActionCreated to use the previous visible message. let optimisticReport: Partial = { - lastMessageTranslationKey: '', lastMessageText: '', lastVisibleActionCreated: '', }; - const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportUtils.getLastVisibleMessage(originalReportID, optimisticReportActions as ReportActions); + const {lastMessageText = ''} = ReportUtils.getLastVisibleMessage(originalReportID, optimisticReportActions as ReportActions); const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; const canUserPerformWriteAction = ReportUtils.canUserPerformWriteAction(report); - if (lastMessageText || lastMessageTranslationKey) { + if (lastMessageText) { const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(originalReportID, canUserPerformWriteAction, optimisticReportActions as ReportActions); const lastVisibleActionCreated = lastVisibleAction?.created; const lastActorAccountID = lastVisibleAction?.actorAccountID; optimisticReport = { - lastMessageTranslationKey, lastMessageText, lastVisibleActionCreated, lastActorAccountID, @@ -1774,7 +1769,6 @@ function editReportComment(reportID: string, originalReportAction: OnyxEntry = { - lastMessageTranslationKey: '', lastMessageText: '', lastVisibleActionCreated: '', hasOutstandingChildTask: false, }; const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${targetChatReportID}`]; const canUserPerformWriteAction = ReportUtils.canUserPerformWriteAction(report); - const {lastMessageText = '', lastMessageTranslationKey = ''} = ReportActionsUtils.getLastVisibleMessage(targetChatReportID, canUserPerformWriteAction); - if (lastMessageText || lastMessageTranslationKey) { + const {lastMessageText = ''} = ReportActionsUtils.getLastVisibleMessage(targetChatReportID, canUserPerformWriteAction); + if (lastMessageText) { const lastVisibleAction = ReportActionsUtils.getLastVisibleAction(targetChatReportID, canUserPerformWriteAction); const prevLastVisibleActionCreated = lastVisibleAction?.created; const lastActorAccountID = lastVisibleAction?.actorAccountID; failureReport = { - lastMessageTranslationKey, lastMessageText, lastVisibleActionCreated: prevLastVisibleActionCreated, lastActorAccountID, @@ -4177,7 +4169,6 @@ function resolveActionableMentionWhisper(reportId: string, reportAction: OnyxEnt const reportUpdateDataWithPreviousLastMessage = ReportUtils.getReportLastMessage(reportId, optimisticReportActions as ReportActions); const reportUpdateDataWithCurrentLastMessage = { - lastMessageTranslationKey: report?.lastMessageTranslationKey, lastMessageText: report?.lastMessageText, lastVisibleActionCreated: report?.lastVisibleActionCreated, lastActorAccountID: report?.lastActorAccountID, @@ -4252,7 +4243,6 @@ function resolveActionableReportMentionWhisper( const reportUpdateDataWithPreviousLastMessage = ReportUtils.getReportLastMessage(reportId, optimisticReportActions as ReportActions); const reportUpdateDataWithCurrentLastMessage = { - lastMessageTranslationKey: report?.lastMessageTranslationKey, lastMessageText: report?.lastMessageText, lastVisibleActionCreated: report?.lastVisibleActionCreated, lastActorAccountID: report?.lastActorAccountID, diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index bd61f9b5c17a..2b4b8fe73ccc 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -142,7 +142,6 @@ function createTaskAndNavigate( lastMessageText: lastCommentText, lastActorAccountID: currentUserAccountID, lastReadTime: currentTime, - lastMessageTranslationKey: '', hasOutstandingChildTask: assigneeAccountID === currentUserAccountID ? true : parentReport?.hasOutstandingChildTask, }; diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index b89b6c8e0777..4c7909169fc4 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -148,9 +148,6 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** Invoice room receiver data */ invoiceReceiver?: InvoiceReceiver; - /** Translation key of the last message in the report */ - lastMessageTranslationKey?: string; - /** ID of the parent report of the current report, if it exists */ parentReportID?: string; diff --git a/src/types/utils/whitelistedReportKeys.ts b/src/types/utils/whitelistedReportKeys.ts index 015420683925..059453be47ba 100644 --- a/src/types/utils/whitelistedReportKeys.ts +++ b/src/types/utils/whitelistedReportKeys.ts @@ -33,7 +33,6 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback< type: unknown; visibility: unknown; invoiceReceiver: unknown; - lastMessageTranslationKey: unknown; parentReportID: unknown; parentReportActionID: unknown; managerID: unknown;