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
12 changes: 2 additions & 10 deletions src/components/AvatarWithDisplayName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import {getPersonalDetailsForAccountIDs} from '@libs/OptionsListUtils';
import {getReportName} from '@libs/ReportNameUtils';
import type {DisplayNameWithTooltips} from '@libs/ReportUtils';
import {
getChatRoomSubtitle,
getDisplayNamesWithTooltips,
getParentNavigationSubtitle,
getReportName,
getReportStatusColorStyle,
getReportStatusTranslation,
isChatThread,
Expand Down Expand Up @@ -181,17 +181,9 @@ function AvatarWithDisplayName({
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`, {canBeMissing: true});
const [invoiceReceiverPolicy] = useOnyx(
`${ONYXKEYS.COLLECTION.POLICY}${parentReport?.invoiceReceiver && 'policyID' in parentReport.invoiceReceiver ? parentReport.invoiceReceiver.policyID : undefined}`,
{canBeMissing: true},
);
const reportAttributes = useReportAttributes();
const parentReportActionParam = report?.parentReportActionID ? parentReportActions?.[report.parentReportActionID] : undefined;
const isReportArchived = useReportIsArchived(report?.reportID);
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line @typescript-eslint/no-deprecated
const title = getReportName(report, undefined, parentReportActionParam, personalDetails, invoiceReceiverPolicy, reportAttributes, undefined, isReportArchived);
const title = getReportName(report, reportAttributes);

Choose a reason for hiding this comment

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

P2 Badge Preserve unapproved-thread title generation

Switching this header to ReportNameUtils.getReportName(report, reportAttributes) drops the legacy handling for CREATED_REPORT_FOR_UNAPPROVED_TRANSACTIONS threads that existed in ReportUtils.getReportName (see src/libs/ReportUtils.ts around the branch that builds getCreatedReportForUnapprovedTransactionsMessage). ReportNameUtils.getReportName only reads derived reportAttributes, and computeReportName has no equivalent branch, so these auto-created threads can now render a blank or generic participant-based title instead of the expected system message.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eVoloshchak What do you think about the bot's feedback?

Copy link
Contributor

Choose a reason for hiding this comment

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

@waterim do you remember why this part handling CREATED_REPORT_FOR_UNAPPROVED_TRANSACTIONS is not present in new getReportName?

Copy link
Contributor

Choose a reason for hiding this comment

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

It was actually just added 2 month ago, we need to update the new function to support it

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Fix PR: #83460

Copy link
Contributor

Choose a reason for hiding this comment

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

I doubt if this is really needed. See my comment to original implementation: https://github.com/Expensify/App/pull/78267/changes#r2857877391

const isParentReportArchived = useReportIsArchived(report?.parentReportID);
const subtitle = getChatRoomSubtitle(report, true, isReportArchived);
const parentNavigationSubtitleData = getParentNavigationSubtitle(report, isParentReportArchived, reportAttributes);
Expand Down
4 changes: 3 additions & 1 deletion src/components/ReportWelcomeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import useEnvironment from '@hooks/useEnvironment';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePreferredPolicy from '@hooks/usePreferredPolicy';
import useReportAttributes from '@hooks/useReportAttributes';
import useReportIsArchived from '@hooks/useReportIsArchived';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
Expand Down Expand Up @@ -53,6 +54,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
const {translate, localeCompare} = useLocalize();
const styles = useThemeStyles();
const {environmentURL} = useEnvironment();
const reportAttributes = useReportAttributes();
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsSelector, canBeMissing: false});
const {isRestrictedToPreferredPolicy} = usePreferredPolicy();
const isPolicyExpenseChat = isPolicyExpenseChatReportUtils(report);
Expand Down Expand Up @@ -89,7 +91,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) {
)}`,
)
.join(', ');
const reportName = getReportName(report);
const reportName = getReportName(report, reportAttributes);
const shouldShowUsePlusButtonText =
moneyRequestOptions.includes(CONST.IOU.TYPE.PAY) ||
moneyRequestOptions.includes(CONST.IOU.TYPE.SUBMIT) ||
Expand Down
8 changes: 5 additions & 3 deletions src/pages/RoomInvitePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
import useDebouncedState from '@hooks/useDebouncedState';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useReportAttributes from '@hooks/useReportAttributes';
import useReportIsArchived from '@hooks/useReportIsArchived';
import useThemeStyles from '@hooks/useThemeStyles';
import {inviteToRoom, inviteToRoomAction, searchInServer} from '@libs/actions/Report';
Expand All @@ -38,7 +39,8 @@ import type {MemberEmailsToAccountIDs} from '@libs/PolicyUtils';
import {isPolicyEmployee as isPolicyEmployeeUtil} from '@libs/PolicyUtils';
import {getReportAction} from '@libs/ReportActionsUtils';
import type {OptionData} from '@libs/ReportUtils';
import {getReportName, isHiddenForCurrentUser, isPolicyExpenseChat} from '@libs/ReportUtils';
import {getReportName} from '@libs/ReportNameUtils';
import {isHiddenForCurrentUser, isPolicyExpenseChat} from '@libs/ReportUtils';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
Expand All @@ -60,6 +62,7 @@ function RoomInvitePage({
},
}: RoomInvitePageProps) {
const styles = useThemeStyles();
const reportAttributes = useReportAttributes();
const {translate, formatPhoneNumber} = useLocalize();
const [userSearchPhrase] = useOnyx(ONYXKEYS.ROOM_MEMBERS_USER_SEARCH_PHRASE, {canBeMissing: true});
const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});
Expand Down Expand Up @@ -199,8 +202,7 @@ function RoomInvitePage({
const shouldParserToHTML = reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT;
const backRoute = reportID && (!isPolicyEmployee || isReportArchived ? ROUTES.REPORT_WITH_ID_DETAILS.getRoute(reportID, backTo) : ROUTES.ROOM_MEMBERS.getRoute(reportID, backTo));

// eslint-disable-next-line @typescript-eslint/no-deprecated
const reportName = getReportName(report);
const reportName = getReportName(report, reportAttributes);

const ancestors = useAncestors(report);

Expand Down
9 changes: 6 additions & 3 deletions src/pages/RoomMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import useLocalize from '@hooks/useLocalize';
import useMobileSelectionMode from '@hooks/useMobileSelectionMode';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import useReportAttributes from '@hooks/useReportAttributes';
import useReportIsArchived from '@hooks/useReportIsArchived';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useSearchBackPress from '@hooks/useSearchBackPress';
Expand All @@ -39,9 +40,9 @@ import Parser from '@libs/Parser';
import {getDisplayNameOrDefault, getPersonalDetailsByIDs} from '@libs/PersonalDetailsUtils';
import {isPolicyAdmin, isPolicyEmployee as isPolicyEmployeeUtils} from '@libs/PolicyUtils';
import {getReportAction} from '@libs/ReportActionsUtils';
import {getReportName} from '@libs/ReportNameUtils';
import {
getReportForHeader,
getReportName,
getReportPersonalDetailsParticipants,
isChatThread,
isDefaultRoom,
Expand All @@ -68,6 +69,7 @@ function RoomMembersPage({report, policy}: RoomMembersPageProps) {
const reportAction = useMemo(() => getReportAction(report?.parentReportID, report?.parentReportActionID), [report?.parentReportID, report?.parentReportActionID]);
const shouldParserToHTML = reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT;
const styles = useThemeStyles();
const reportAttributes = useReportAttributes();
const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false});
const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${report?.reportID}`, {canBeMissing: false});
const currentUserAccountID = Number(session?.accountID);
Expand Down Expand Up @@ -442,8 +444,9 @@ function RoomMembersPage({report, policy}: RoomMembersPageProps) {
>
<HeaderWithBackButton
title={selectionModeHeader ? translate('common.selectMultiple') : translate('workspace.common.members')}
// eslint-disable-next-line @typescript-eslint/no-deprecated
subtitle={StringUtils.lineBreaksToSpaces(shouldParserToHTML ? Parser.htmlToText(getReportName(reportForSubtitle)) : getReportName(reportForSubtitle))}
subtitle={StringUtils.lineBreaksToSpaces(
shouldParserToHTML ? Parser.htmlToText(getReportName(reportForSubtitle, reportAttributes)) : getReportName(reportForSubtitle, reportAttributes),
)}
onBackButtonPress={() => {
if (isMobileSelectionModeEnabled) {
setSelectedMembers([]);
Expand Down
7 changes: 4 additions & 3 deletions src/pages/ShareCodePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
import useEnvironment from '@hooks/useEnvironment';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useReportAttributes from '@hooks/useReportAttributes';
import useReportIsArchived from '@hooks/useReportIsArchived';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import Clipboard from '@libs/Clipboard';
import Navigation from '@libs/Navigation/Navigation';
import type {BackToParams} from '@libs/Navigation/types';
import {getReportName} from '@libs/ReportNameUtils';
import {
getChatRoomSubtitle,
getDefaultWorkspaceAvatar,
Expand All @@ -31,7 +33,6 @@ import {
getParticipantsAccountIDsForDisplay,
getPolicyName,
getReportForHeader,
getReportName,
isExpenseReport,
isMoneyRequestReport,
} from '@libs/ReportUtils';
Expand Down Expand Up @@ -78,6 +79,7 @@ function ShareCodePage({report, policy, backTo}: ShareCodePageProps) {
const qrCodeRef = useRef<QRShareWithDownloadHandle>(null);

const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const reportAttributes = useReportAttributes();
const isParentReportArchived = useReportIsArchived(report?.parentReportID);
const isReportArchived = useReportIsArchived(report?.reportID);
const isReport = !!report?.reportID;
Expand All @@ -102,8 +104,7 @@ function ShareCodePage({report, policy, backTo}: ShareCodePageProps) {

const reportForTitle = useMemo(() => getReportForHeader(report), [report]);

// eslint-disable-next-line @typescript-eslint/no-deprecated
const title = isReport ? getReportName(reportForTitle) : (currentUserPersonalDetails.displayName ?? '');
const title = isReport ? getReportName(reportForTitle, reportAttributes) : (currentUserPersonalDetails.displayName ?? '');
const urlWithTrailingSlash = addTrailingForwardSlash(environmentURL);
const url = isReport
? `${urlWithTrailingSlash}${ROUTES.REPORT_WITH_ID.getRoute(report.reportID)}`
Expand Down
6 changes: 4 additions & 2 deletions src/pages/TripChatNameEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import ScreenWrapper from '@components/ScreenWrapper';
import TextInput from '@components/TextInput';
import useAutoFocusInput from '@hooks/useAutoFocusInput';
import useLocalize from '@hooks/useLocalize';
import useReportAttributes from '@hooks/useReportAttributes';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {NewChatNavigatorParamList} from '@libs/Navigation/types';
import {getReportName} from '@libs/ReportUtils';
import {getReportName} from '@libs/ReportNameUtils';
import StringUtils from '@libs/StringUtils';
import {updateChatName} from '@userActions/Report';
import CONST from '@src/CONST';
Expand All @@ -28,11 +29,12 @@ type TripChatNameEditPageProps = Partial<PlatformStackScreenProps<NewChatNavigat

function TripChatNameEditPage({report}: TripChatNameEditPageProps) {
const styles = useThemeStyles();
const reportAttributes = useReportAttributes();
const {translate} = useLocalize();
const {inputCallbackRef} = useAutoFocusInput();

const reportID = report?.reportID;
const currentChatName = getReportName(report);
const currentChatName = getReportName(report, reportAttributes);

const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.NEW_CHAT_NAME_FORM>): Errors => {
const errors: Errors = {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React, {useMemo} from 'react';
import useDefaultAvatars from '@hooks/useDefaultAvatars';
import useOnyx from '@hooks/useOnyx';
import {getDefaultGroupAvatar, getPolicyName, getReportName, getWorkspaceIcon, isGroupChat, isThread, isUserCreatedPolicyRoom} from '@libs/ReportUtils';
import useReportAttributes from '@hooks/useReportAttributes';
import {getReportName} from '@libs/ReportNameUtils';
import {getDefaultGroupAvatar, getPolicyName, getWorkspaceIcon, isGroupChat, isThread, isUserCreatedPolicyRoom} from '@libs/ReportUtils';
import {getFullSizeAvatar} from '@libs/UserAvatarUtils';
import type {AttachmentModalBaseContentProps} from '@pages/media/AttachmentModalScreen/AttachmentModalBaseContent/types';
import AttachmentModalContainer from '@pages/media/AttachmentModalScreen/AttachmentModalContainer';
Expand All @@ -17,29 +19,20 @@ function ReportAvatarModalContent({navigation, route}: AttachmentModalScreenProp
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: false});
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {canBeMissing: true});
const [isLoadingApp = true] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true});
const reportAttributes = useReportAttributes();

const attachment: AttachmentModalBaseContentProps = useMemo(() => {
if (isGroupChat(report) && !isThread(report)) {
return {
source: report?.avatarUrl ? getFullSizeAvatar({avatarSource: report.avatarUrl, defaultAvatars}) : getDefaultGroupAvatar(report?.reportID),
// eslint-disable-next-line @typescript-eslint/no-deprecated
headerTitle: getReportName(report),
headerTitle: getReportName(report, reportAttributes),
isWorkspaceAvatar: false,
};
}
if (isUserCreatedPolicyRoom(report) && report?.avatarUrl) {
return {
source: getFullSizeAvatar({avatarSource: report.avatarUrl, defaultAvatars}),
// eslint-disable-next-line @typescript-eslint/no-deprecated
headerTitle: getReportName(report),
isWorkspaceAvatar: false,
};
}
if (isUserCreatedPolicyRoom(report) && report?.avatarUrl) {
return {
source: getFullSizeAvatar({avatarSource: report.avatarUrl, defaultAvatars}),
// eslint-disable-next-line @typescript-eslint/no-deprecated
headerTitle: getReportName(report),
headerTitle: getReportName(report, reportAttributes),
isWorkspaceAvatar: false,
};
}
Expand All @@ -51,7 +44,7 @@ function ReportAvatarModalContent({navigation, route}: AttachmentModalScreenProp
originalFileName: policy?.originalFileName ?? policy?.id ?? report?.policyID,
isWorkspaceAvatar: true,
};
}, [policy, report, defaultAvatars]);
}, [policy, report, defaultAvatars, reportAttributes]);

const onDownloadAttachment = useDownloadAttachment();

Expand Down
Loading