Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libs/ModifiedExpenseMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}) ||
Expand Down Expand Up @@ -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')});
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 8 additions & 6 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 ?? '';
}
Expand Down Expand Up @@ -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');
Expand All @@ -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);

Expand Down Expand Up @@ -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);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/libs/SearchQueryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ import {
isResolvedActionableWhisper,
isWhisperActionTargetedToOthers,
} from './ReportActionsUtils';
import {deprecatedGetReportName} from './ReportNameUtils';
import {getReportName} from './ReportNameUtils';
import {isExportAction} from './ReportPrimaryActionUtils';
import {
canDeleteMoneyRequestReport,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ import {
isTagModificationAction,
isTaskAction,
} from './ReportActionsUtils';
import {deprecatedGetReportName} from './ReportNameUtils';
import {deprecatedGetReportName, getReportName} from './ReportNameUtils';
import {
canUserPerformWriteAction as canUserPerformWriteActionUtil,
excludeParticipantsForDisplay,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't pass reportAttributes in getShareDestination anymore; passing a reportName should be enough. With this reafctor, we need to avoid subscribing to the entire reportAttributes at the component level

subtitle,
displayNamesWithTooltips,
shouldUseFullTitleToDisplay: ReportUtils.shouldUseFullTitleToDisplay(report),
Expand Down
Loading