Skip to content

Commit 22f7828

Browse files
authored
Merge pull request Expensify#75988 from whiletrace/hotf#75457-v2
Group - Group chat header hidden; tap shows empty name while preview…
2 parents 4c22c76 + b8a84ca commit 22f7828

5 files changed

Lines changed: 83 additions & 3 deletions

File tree

src/components/DisplayNames/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ type DisplayNamesProps = ForwardedFSClassProps & {
5252
/** If we should add an ellipsis after the participants list */
5353
shouldAddEllipsis?: boolean;
5454

55+
/** Whether to parse HTML in the title */
56+
shouldParseHtml?: boolean;
57+
5558
/** Additional Text component to render after the displayNames */
5659
renderAdditionalText?: () => React.ReactNode;
5760

src/pages/ReportDetailsPage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
338338
const shouldShowLeaveButton = canLeaveChat(report, policy, !!reportNameValuePairs?.private_isArchived);
339339
const shouldShowGoToWorkspace = shouldShowPolicy(policy, false, currentUserPersonalDetails?.email) && !policy?.isJoinRequestPending;
340340

341-
const reportName = Parser.htmlToText(getReportNameFromReportNameUtils(report, reportAttributes));
341+
const reportName = isGroupChat ? getReportNameFromReportNameUtils(report, reportAttributes) : Parser.htmlToText(getReportNameFromReportNameUtils(report, reportAttributes));
342342
const additionalRoomDetails =
343343
(isPolicyExpenseChat && !!report?.isOwnPolicyExpenseChat) || isExpenseReportUtil(report) || isPolicyExpenseChat || isInvoiceRoom
344344
? chatRoomSubtitle
@@ -550,6 +550,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
550550
isSelfDM,
551551
isArchivedRoom,
552552
isGroupChat,
553+
expensifyIcons,
553554
isDefaultRoom,
554555
isChatThread,
555556
isPolicyEmployee,
@@ -665,6 +666,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
665666
policy,
666667
participants,
667668
moneyRequestReport?.reportID,
669+
expensifyIcons.Camera,
668670
]);
669671

670672
const canJoin = canJoinChat(report, parentReportAction, policy, !!reportNameValuePairs?.private_isArchived);
@@ -693,6 +695,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
693695
<DisplayNames
694696
fullTitle={reportName}
695697
displayNamesWithTooltips={displayNamesWithTooltips}
698+
shouldParseFullTitle={!isGroupChat}
696699
tooltipEnabled
697700
numberOfLines={isChatRoom && !isChatThread ? 0 : 1}
698701
textStyles={[styles.textHeadline, styles.textAlignCenter, isChatRoom && !isChatThread ? undefined : styles.pre]}

src/pages/home/HeaderView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
156156
const isPersonalExpenseChat = isPolicyExpenseChat && isCurrentUserSubmitter(report);
157157
const hasTeam2025Pricing = useHasTeam2025Pricing();
158158
// This is used to ensure that we display the text exactly as the user entered it when displaying thread header text, instead of parsing their text to HTML.
159-
const shouldParseFullTitle = parentReportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT;
159+
const shouldParseFullTitle = parentReportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT && !isGroupChat;
160160
const subscriptionPlan = useSubscriptionPlan();
161161
const ancestors = useAncestors(report);
162162

@@ -303,7 +303,7 @@ function HeaderView({report, parentReportAction, onNavigationMenuButtonClicked,
303303
<DisplayNames
304304
fullTitle={title}
305305
displayNamesWithTooltips={displayNamesWithTooltips}
306-
shouldParseFullTitle={shouldParseFullTitle}
306+
shouldParseFullTitle={shouldParseFullTitle && !isGroupChat}
307307
tooltipEnabled
308308
numberOfLines={1}
309309
textStyles={[styles.headerText, styles.pre]}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import {render, screen} from '@testing-library/react-native';
2+
import React from 'react';
3+
import DisplayNames from '@components/DisplayNames';
4+
import Parser from '@libs/Parser';
5+
6+
jest.mock('@libs/Parser', () => ({
7+
// eslint-disable-next-line @typescript-eslint/naming-convention
8+
__esModule: true,
9+
default: {
10+
htmlToText: jest.fn((html: string) => html.replaceAll(/<[^>]*>/g, '')),
11+
},
12+
}));
13+
14+
jest.mock('@hooks/useLocalize', () => ({
15+
// eslint-disable-next-line @typescript-eslint/naming-convention
16+
__esModule: true,
17+
default: jest.fn(() => ({
18+
translate: jest.fn((key: string) => key),
19+
})),
20+
}));
21+
22+
// eslint-disable-next-line @typescript-eslint/unbound-method
23+
const mockHtmlToText = Parser.htmlToText as jest.Mock;
24+
25+
describe('DisplayNames HTML Parsing', () => {
26+
beforeEach(() => {
27+
jest.clearAllMocks();
28+
});
29+
30+
describe('DisplayNames Component - shouldParseFullTitle prop', () => {
31+
it('should parse HTML when shouldParseFullTitle is true', () => {
32+
const htmlTitle = '<strong>Test Title</strong>';
33+
34+
render(
35+
<DisplayNames
36+
fullTitle={htmlTitle}
37+
numberOfLines={1}
38+
shouldParseFullTitle
39+
/>,
40+
);
41+
42+
expect(mockHtmlToText).toHaveBeenCalledWith(htmlTitle);
43+
expect(mockHtmlToText).toHaveBeenCalledTimes(1);
44+
});
45+
46+
it('should NOT parse HTML when shouldParseFullTitle is false', () => {
47+
const htmlTitle = '<strong>Test Title</strong>';
48+
49+
render(
50+
<DisplayNames
51+
fullTitle={htmlTitle}
52+
numberOfLines={1}
53+
shouldParseFullTitle={false}
54+
/>,
55+
);
56+
expect(mockHtmlToText).not.toHaveBeenCalled();
57+
expect(screen.getByText(htmlTitle)).toBeTruthy();
58+
});
59+
60+
it('HTML is parsed by default when shouldParseFullTitle is not provided', () => {
61+
const htmlTitle = '<em>Test Title </em>';
62+
63+
render(
64+
<DisplayNames
65+
fullTitle={htmlTitle}
66+
numberOfLines={1}
67+
/>,
68+
);
69+
70+
expect(mockHtmlToText).toHaveBeenCalledWith(htmlTitle);
71+
});
72+
});
73+
});

tests/unit/Search/SearchContextTest.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const mockTransaction = {
5757
transactionID: '1',
5858
action: 'approve',
5959
allActions: ['approve'],
60+
canDelete: true,
6061
formattedFrom: 'Main Applause QA',
6162
formattedTo: 'Main Applause QA',
6263
formattedTotal: -1284,

0 commit comments

Comments
 (0)