diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index a0b6fd24c370..61e7692a7b89 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -33,7 +33,7 @@ import {getOriginalMessage, isModifiedExpenseAction} from './ReportActionsUtils' // The functions imported here are pure utility functions that don't create initialization-time dependencies. // ReportNameUtils imports helper functions from ReportUtils, and ReportUtils imports name generation functions from ReportNameUtils. // eslint-disable-next-line import/no-cycle -import {buildReportNameFromParticipantNames, deprecatedGetReportName, getPolicyExpenseChatName} from './ReportNameUtils'; +import {buildReportNameFromParticipantNames, getPolicyExpenseChatName, getReportName} from './ReportNameUtils'; import {getPolicyName, getRootParentReport, isPolicyExpenseChat, isSelfDM} from './ReportUtils'; import {getFormattedAttendees, getTagArrayFromName} from './TransactionUtils'; import {isInvalidMerchantValue} from './ValidationUtils'; @@ -196,7 +196,7 @@ function getMovedFromOrToReportMessage( } if (movedFromReport) { - const originReportName = deprecatedGetReportName(movedFromReport, reportAttributes); + const originReportName = getReportName(movedFromReport, reportAttributes?.[movedFromReport.reportID]?.reportName); return originReportName ? translate('iou.movedFromReport', originReportName) : translate('iou.movedFromReportNoName'); } } diff --git a/src/libs/Notification/LocalNotification/BrowserNotifications.ts b/src/libs/Notification/LocalNotification/BrowserNotifications.ts index b53e061b4188..0840186c311e 100644 --- a/src/libs/Notification/LocalNotification/BrowserNotifications.ts +++ b/src/libs/Notification/LocalNotification/BrowserNotifications.ts @@ -6,7 +6,7 @@ import Log from '@libs/Log'; import {getForReportAction} from '@libs/ModifiedExpenseMessage'; import NotificationPermission from '@libs/Notification/notificationPermission'; import {getTextFromHtml} from '@libs/ReportActionsUtils'; -import {deprecatedGetReportName} from '@libs/ReportNameUtils'; +import {getReportName} from '@libs/ReportNameUtils'; import * as ReportUtils from '@libs/ReportUtils'; import playSound, {SOUNDS} from '@libs/Sound'; @@ -134,7 +134,7 @@ export default { } if (isRoomOrGroupChat) { - const roomName = deprecatedGetReportName(report, reportAttributes); + const roomName = getReportName(report, reportAttributes?.[report.reportID]?.reportName); title = roomName; body = `${plainTextPerson}: ${plainTextMessage}`; } else { diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 06939caa81fa..f304f67283f2 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -111,7 +111,7 @@ import { wasActionTakenByCurrentUser, withDEWRoutedActionsArray, } from '@libs/ReportActionsUtils'; -import {deprecatedGetReportName} from '@libs/ReportNameUtils'; +import {getReportName} from '@libs/ReportNameUtils'; import type {OptionData} from '@libs/ReportUtils'; import { canUserPerformWriteAction, @@ -1212,7 +1212,7 @@ function createOption({ }, ); - const computedReportName = deprecatedGetReportName(report, reportAttributesDerived); + const computedReportName = getReportName(report, report?.reportID ? reportAttributesDerived?.[report.reportID]?.reportName : undefined); reportName = showPersonalDetails ? getDisplayNameForParticipant({accountID: accountIDs.at(0), formatPhoneNumber: formatPhoneNumberPhoneUtils, translate: translateFn}) || @@ -1297,7 +1297,7 @@ function getReportOption( if (option.isSelfDM) { option.alternateText = translate('reportActionsView.yourSpace'); } else if (option.isInvoiceRoom) { - option.text = deprecatedGetReportName(report, reportAttributesDerived); + option.text = getReportName(report, report?.reportID ? reportAttributesDerived?.[report.reportID]?.reportName : undefined); option.alternateText = translate('workspace.common.invoices'); } else { option.text = getPolicyName({report, policy, unavailableTranslation: translate('workspace.common.unavailable')}); @@ -1355,7 +1355,7 @@ function getReportDisplayOption( if (option.isSelfDM) { option.alternateText = translate('reportActionsView.yourSpace'); } else if (option.isInvoiceRoom) { - option.text = deprecatedGetReportName(report, reportAttributesDerived); + option.text = getReportName(report, report?.reportID ? reportAttributesDerived?.[report.reportID]?.reportName : undefined); option.alternateText = translate('workspace.common.invoices'); } else if (unknownUserDetails) { option.text = unknownUserDetails.text ?? unknownUserDetails.login; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 9b3d8ca23dc0..7ef45dbd6805 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -241,7 +241,7 @@ import { // The functions imported here are pure utility functions that don't create initialization-time dependencies. // ReportNameUtils imports helper functions from ReportUtils, and ReportUtils imports name generation functions from ReportNameUtils. // eslint-disable-next-line import/no-cycle -import {deprecatedGetReportName, getGroupChatName, getInvoicePayerName, getInvoiceReportName} from './ReportNameUtils'; +import {getGroupChatName, getInvoicePayerName, getInvoiceReportName, getReportName} from './ReportNameUtils'; import {shouldRestrictUserBillableActions} from './SubscriptionUtils'; import {isTaskCompleted} from './TaskUtils'; import { @@ -5693,7 +5693,8 @@ function getReportPreviewMessageForCopy( const originalReportAction = params.originalReportAction ?? iouReportAction; const report = typeof reportOrID === 'string' ? getReport(reportOrID, deprecatedAllReports) : reportOrID; if (report) { - return deprecatedGetReportName(report, reportAttributes ?? reportAttributesDerivedValue) || (originalReportAction?.childReportName ?? ''); + const attributes = reportAttributes ?? reportAttributesDerivedValue; + return getReportName(report, attributes?.[report.reportID]?.reportName) || (originalReportAction?.childReportName ?? ''); } return originalReportAction?.childReportName ?? ''; } @@ -7188,7 +7189,7 @@ function getMovedTransactionMessage(translate: LocalizedTranslate, action: Repor const report = fromReport ?? toReport; - const reportName = Parser.htmlToText(deprecatedGetReportName(report, reportAttributes) ?? report?.reportName ?? ''); + const reportName = Parser.htmlToText(getReportName(report, report?.reportID ? reportAttributes?.[report.reportID]?.reportName : undefined)); const reportUrl = getReportURLForCurrentContext(report?.reportID); if (typeof fromReportID === 'undefined') { return reportName ? translate('iou.movedTransactionTo', reportUrl, reportName) : translate('iou.movedTransactionToAnotherReport'); @@ -7202,7 +7203,7 @@ function getUnreportedTransactionMessage(translate: LocalizedTranslate, action: const fromReport = deprecatedAllReports?.[`${ONYXKEYS.COLLECTION.REPORT}${fromReportID}`]; - const reportName = Parser.htmlToText(deprecatedGetReportName(fromReport, reportAttributes) ?? fromReport?.reportName ?? ''); + const reportName = Parser.htmlToText(getReportName(fromReport, fromReport?.reportID ? reportAttributes?.[fromReport.reportID]?.reportName : undefined)); let reportUrl = getReportURLForCurrentContext(fromReportID); @@ -13115,10 +13116,11 @@ function getChatListItemReportName(action: ReportAction & {reportName?: string}, } if (report?.reportID) { - return deprecatedGetReportName(getReport(report?.reportID, deprecatedAllReports), reportAttributesDerivedValue); + const fullReport = getReport(report.reportID, deprecatedAllReports); + return getReportName(fullReport, fullReport?.reportID ? reportAttributesDerivedValue?.[fullReport.reportID]?.reportName : undefined); } - return deprecatedGetReportName(report, reportAttributesDerivedValue); + return getReportName(report, report?.reportID ? reportAttributesDerivedValue?.[report.reportID]?.reportName : undefined); } /** diff --git a/src/libs/SearchQueryUtils.ts b/src/libs/SearchQueryUtils.ts index 2a20f4ceadb8..6015be04d59d 100644 --- a/src/libs/SearchQueryUtils.ts +++ b/src/libs/SearchQueryUtils.ts @@ -65,7 +65,7 @@ import navigationRef from './Navigation/navigationRef'; import {isRecord} from './ObjectUtils'; import {getPersonalDetailByEmail, temporaryGetDisplayNameOrDefault} from './PersonalDetailsUtils'; import {getCleanedTagName, getValidConnectedIntegration} from './PolicyUtils'; -import {deprecatedGetReportName} from './ReportNameUtils'; +import {getReportName} from './ReportNameUtils'; import {parse as parseSearchQuery} from './SearchParser/searchParser'; import StringUtils from './StringUtils'; import {hashText} from './UserUtils'; @@ -1707,7 +1707,8 @@ function getFilterDisplayValue({ return getBankAccountSearchLabel(bankAccount); } if (filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.IN) { - return deprecatedGetReportName(reports?.[`${ONYXKEYS.COLLECTION.REPORT}${filterValue}`], reportAttributes) || filterValue; + const filterReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${filterValue}`]; + return getReportName(filterReport, filterReport?.reportID ? reportAttributes?.[filterReport.reportID]?.reportName : undefined) || filterValue; } if (filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT || filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.TOTAL || filterName === CONST.SEARCH.SYNTAX_FILTER_KEYS.PURCHASE_AMOUNT) { // Added 2 here as this is the maximum number of decimals an amount can have. So, we can run a search with 2 decimals here. diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index e1e6c25d7569..c885f29d3551 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -141,7 +141,7 @@ import { isResolvedActionableWhisper, isWhisperActionTargetedToOthers, } from './ReportActionsUtils'; -import {deprecatedGetReportName} from './ReportNameUtils'; +import {getReportName} from './ReportNameUtils'; import {isExportAction} from './ReportPrimaryActionUtils'; import { canDeleteMoneyRequestReport, @@ -2608,7 +2608,7 @@ function getTaskSections( if (parentReport && personalDetails) { const policy = data[`${ONYXKEYS.COLLECTION.POLICY}${parentReport.policyID}`]; const isParentReportArchived = isArchivedReport(reportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${parentReport?.reportID}`]); - const parentReportName = deprecatedGetReportName(parentReport, reportAttributesDerivedValue); + const parentReportName = getReportName(parentReport, parentReport?.reportID ? reportAttributesDerivedValue?.[parentReport.reportID]?.reportName : undefined); const icons = getIcons(parentReport, formatPhoneNumber, translate, personalDetails, null, '', -1, policy, undefined, isParentReportArchived); const parentReportIcon = icons?.at(0); @@ -2780,7 +2780,7 @@ function getReportActionsSections( ...reportAction, reportID, from, - reportName: deprecatedGetReportName(report, reportAttributesDerivedValue), + reportName: getReportName(report, report?.reportID ? reportAttributesDerivedValue?.[report.reportID]?.reportName : undefined), formattedFrom: from?.displayName ?? from?.login ?? '', date: reportAction.created, keyForList: reportAction.reportActionID, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 2ce0c0284d63..4b61c673280d 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -152,7 +152,7 @@ import { isTagModificationAction, isTaskAction, } from './ReportActionsUtils'; -import {deprecatedGetReportName} from './ReportNameUtils'; +import {deprecatedGetReportName, getReportName} from './ReportNameUtils'; import { canUserPerformWriteAction as canUserPerformWriteActionUtil, excludeParticipantsForDisplay, @@ -573,7 +573,7 @@ function categorizeReportsForLHN( } const reportID = report.reportID; - const displayName = deprecatedGetReportName(report, reportAttributes); + const displayName = getReportName(report, reportAttributes?.[report.reportID]?.reportName); const miniReport: MiniReport = { reportID, displayName, @@ -1064,7 +1064,9 @@ function getOptionData({ : translate('workspace.invite.removed'); const users = translate(targetAccountIDsLength > 1 ? 'common.members' : 'common.member')?.toLocaleLowerCase(); result.alternateText = formatReportLastMessageText(`${actorDisplayName ?? lastActorDisplayName}: ${verb} ${targetAccountIDsLength} ${users}`); - const roomName = deprecatedGetReportName(lastActionReport ?? undefined, reportAttributesDerived) || lastActionOriginalMessage?.roomName; + const roomName = + getReportName(lastActionReport ?? undefined, lastActionReport?.reportID ? reportAttributesDerived?.[lastActionReport.reportID]?.reportName : undefined) || + lastActionOriginalMessage?.roomName; if (roomName) { const preposition = lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM @@ -1382,7 +1384,7 @@ function getOptionData({ result.phoneNumber = personalDetail?.phoneNumber ?? ''; } - const reportName = deprecatedGetReportName(report, reportAttributesDerived); + const reportName = getReportName(report, report?.reportID ? reportAttributesDerived?.[report.reportID]?.reportName : undefined); result.text = reportName; result.subtitle = subtitle; diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 452a22da784d..4a1a1a2b0cd6 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -14,7 +14,7 @@ import {getDBTimeWithSkew} from '@libs/NetworkState'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; -import {deprecatedGetReportName} from '@libs/ReportNameUtils'; +import {getReportName} from '@libs/ReportNameUtils'; import * as ReportUtils from '@libs/ReportUtils'; import {buildOptimisticSnapshotData} from '@libs/SearchQueryUtils'; import playSound, {SOUNDS} from '@libs/Sound'; @@ -1170,7 +1170,7 @@ function getShareDestination( } return { icons: ReportUtils.getIcons(report, formatPhoneNumber, translate, personalDetails, FallbackAvatar), - displayName: deprecatedGetReportName(report, reportAttributes), + displayName: getReportName(report, report?.reportID ? reportAttributes?.[report.reportID]?.reportName : undefined), subtitle, displayNamesWithTooltips, shouldUseFullTitleToDisplay: ReportUtils.shouldUseFullTitleToDisplay(report),