Skip to content
Merged
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
9 changes: 3 additions & 6 deletions src/components/DisplayNames/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ import TextWithEmojiFragment from '@pages/home/report/comment/TextWithEmojiFragm
import type DisplayNamesProps from './types';

// As we don't have to show tooltips of the Native platform so we simply render the full display names list.
function DisplayNames({accessibilityLabel, fullTitle, textStyles = [], numberOfLines = 1, renderAdditionalText, forwardedFSClass, testID, shouldParseHtml = false}: DisplayNamesProps) {
function DisplayNames({accessibilityLabel, fullTitle, textStyles = [], numberOfLines = 1, renderAdditionalText, forwardedFSClass, testID}: DisplayNamesProps) {
const {translate} = useLocalize();
const title = shouldParseHtml
? StringUtils.lineBreaksToSpaces(Parser.htmlToText(fullTitle)) || translate('common.hidden')
: StringUtils.lineBreaksToSpaces(fullTitle) || translate('common.hidden');
const titleContainsTextAndCustomEmoji = useMemo(() => containsCustomEmoji(fullTitle) && !containsOnlyCustomEmoji(fullTitle), [fullTitle]);
return (
<Text
Expand All @@ -24,11 +21,11 @@ function DisplayNames({accessibilityLabel, fullTitle, textStyles = [], numberOfL
>
{titleContainsTextAndCustomEmoji ? (
<TextWithEmojiFragment
message={title}
message={StringUtils.lineBreaksToSpaces(Parser.htmlToText(fullTitle)) || translate('common.hidden')}
style={textStyles}
/>
) : (
title
StringUtils.lineBreaksToSpaces(Parser.htmlToText(fullTitle)) || translate('common.hidden')
)}
{renderAdditionalText?.()}
</Text>
Expand Down
5 changes: 1 addition & 4 deletions src/components/DisplayNames/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ function DisplayNames({
displayNamesWithTooltips,
renderAdditionalText,
forwardedFSClass,
shouldParseHtml = false,
}: DisplayNamesProps) {
const {translate} = useLocalize();
const title = shouldParseHtml
? StringUtils.lineBreaksToSpaces(Parser.htmlToText(fullTitle)) || translate('common.hidden')
: StringUtils.lineBreaksToSpaces(fullTitle) || translate('common.hidden');
const title = StringUtils.lineBreaksToSpaces(Parser.htmlToText(fullTitle)) || translate('common.hidden');

if (!tooltipEnabled) {
return (
Expand Down
3 changes: 0 additions & 3 deletions src/components/DisplayNames/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ type DisplayNamesProps = ForwardedFSClassProps & {

/** TestID indicating order */
testID?: number;

/** Whether to parse HTML in the fullTitle */
shouldParseHtml?: boolean;
};

export default DisplayNamesProps;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@

let conciergeReportID: OnyxEntry<string>;
Onyx.connect({
key: ONYXKEYS.CONCIERGE_REPORT_ID,

Check warning on line 959 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
callback: (value) => {
conciergeReportID = value;
},
Expand All @@ -964,7 +964,7 @@

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({
key: ONYXKEYS.SESSION,

Check warning on line 967 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
callback: (value) => {
// When signed out, val is undefined
if (!value) {
Expand All @@ -982,7 +982,7 @@
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({
key: ONYXKEYS.PERSONAL_DETAILS_LIST,

Check warning on line 985 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
callback: (value) => {
if (currentUserAccountID) {
currentUserPersonalDetails = value?.[currentUserAccountID] ?? undefined;
Expand All @@ -994,14 +994,14 @@

let allReportsDraft: OnyxCollection<Report>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_DRAFT,

Check warning on line 997 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
});

let allPolicies: OnyxCollection<Policy>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.POLICY,

Check warning on line 1004 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (value) => (allPolicies = value),
});
Expand All @@ -1016,7 +1016,7 @@
let allReports: OnyxCollection<Report>;
let reportsByPolicyID: ReportByPolicyMap;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,

Check warning on line 1019 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (value) => {
allReports = value;
Expand Down Expand Up @@ -1054,14 +1054,14 @@

let allBetas: OnyxEntry<Beta[]>;
Onyx.connect({
key: ONYXKEYS.BETAS,

Check warning on line 1057 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
callback: (value) => (allBetas = value),
});

let allTransactions: OnyxCollection<Transaction> = {};
let reportsTransactions: Record<string, Transaction[]> = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.TRANSACTION,

Check warning on line 1064 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (value) => {
if (!value) {
Expand All @@ -1087,7 +1087,7 @@

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,

Check warning on line 1090 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (actions) => {
if (!actions) {
Expand All @@ -1100,7 +1100,7 @@
let allReportMetadata: OnyxCollection<ReportMetadata>;
const allReportMetadataKeyValue: Record<string, ReportMetadata> = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_METADATA,

Check warning on line 1103 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
waitForCollectionCallback: true,
callback: (value) => {
if (!value) {
Expand Down Expand Up @@ -5682,7 +5682,7 @@
}

if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.UNREPORTED_TRANSACTION)) {
return Parser.htmlToText(getUnreportedTransactionMessage());
return getUnreportedTransactionMessage();
}

if (isActionOfType(parentReportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.UPDATE_MAX_EXPENSE_AMOUNT_NO_RECEIPT)) {
Expand Down
9 changes: 4 additions & 5 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import ConfirmModal from '@components/ConfirmModal';
import DisplayNames from '@components/DisplayNames';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import MentionReportContext from '@components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer/MentionReportContext';
import * as Expensicons from '@components/Icon/Expensicons';
import MenuItem from '@components/MenuItem';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
Expand All @@ -26,7 +27,6 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
import useDeleteTransactions from '@hooks/useDeleteTransactions';
import useDuplicateTransactionsAndViolations from '@hooks/useDuplicateTransactionsAndViolations';
import useGetIOUReportFromReportAction from '@hooks/useGetIOUReportFromReportAction';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
Expand All @@ -41,6 +41,7 @@ import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {ReportDetailsNavigatorParamList} from '@libs/Navigation/types';
import {getPersonalDetailsForAccountIDs} from '@libs/OptionsListUtils';
import Parser from '@libs/Parser';
import Permissions from '@libs/Permissions';
import {isPolicyAdmin as isPolicyAdminUtil, isPolicyEmployee as isPolicyEmployeeUtil, shouldShowPolicy} from '@libs/PolicyUtils';
import {getOneTransactionThreadReportID, getOriginalMessage, getTrackExpenseActionableWhisper, isDeletedAction, isMoneyRequestAction, isTrackExpenseAction} from '@libs/ReportActionsUtils';
Expand Down Expand Up @@ -148,7 +149,6 @@ const CASES = {
type CaseID = ValueOf<typeof CASES>;

function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetailsPageProps) {
const Expensicons = useMemoizedLazyExpensifyIcons(['Bug', 'Building', 'Camera', 'Checkmark', 'Exit', 'Folder', 'Gear', 'Pencil', 'Send', 'Trashcan', 'UserPlus', 'Users'] as const);
const {translate, localeCompare} = useLocalize();
const {isOffline} = useNetwork();
const {isRestrictedToPreferredPolicy, preferredPolicyID} = usePreferredPolicy();
Expand Down Expand Up @@ -332,7 +332,8 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail

const shouldShowLeaveButton = canLeaveChat(report, policy, !!reportNameValuePairs?.private_isArchived);
const shouldShowGoToWorkspace = shouldShowPolicy(policy, false, currentUserPersonalDetails?.email) && !policy?.isJoinRequestPending;
const reportName = getReportName(report, undefined, undefined, undefined, undefined, reportAttributes);

const reportName = Parser.htmlToText(getReportName(report, undefined, undefined, undefined, undefined, reportAttributes));

const additionalRoomDetails =
(isPolicyExpenseChat && !!report?.isOwnPolicyExpenseChat) || isExpenseReportUtil(report) || isPolicyExpenseChat || isInvoiceRoom
Expand Down Expand Up @@ -577,7 +578,6 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
isRestrictedToPreferredPolicy,
preferredPolicyID,
introSelected,
Expensicons,
]);

const displayNamesWithTooltips = useMemo(() => {
Expand Down Expand Up @@ -660,7 +660,6 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
policy,
participants,
moneyRequestReport?.reportID,
Expensicons,
]);

const canJoin = canJoinChat(report, parentReportAction, policy, !!reportNameValuePairs?.private_isArchived);
Expand Down
113 changes: 0 additions & 113 deletions tests/unit/DisplayNamesShouldParseHTMLTest.tsx

This file was deleted.

27 changes: 0 additions & 27 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1125,33 +1125,6 @@ describe('ReportUtils', () => {
);
});
});

describe('Unreported transaction thread', () => {
test('HTML is stripped from unreported transaction message', () => {
const transactionThread = {
...LHNTestUtils.getFakeReport(),
type: CONST.REPORT.TYPE.CHAT,
reportID: '123',
parentReportID: '456',
};

const unreportedTransactionAction = {
actionName: CONST.REPORT.ACTIONS.TYPE.UNREPORTED_TRANSACTION,
originalMessage: {
fromReportID: '789',
},
} as ReportAction;

const reportName = getReportName(transactionThread, undefined, unreportedTransactionAction);

// Should NOT contain HTML tags
expect(reportName).not.toContain('<a href');
expect(reportName).not.toContain('</a>');
// Should contain the text content
expect(reportName).toContain('moved this expense');
expect(reportName).toContain('personal space');
});
});
});

// Need to merge the same tests
Expand Down
Loading