Skip to content

Commit

Permalink
Style / Only apply html render for description and not merchant
Browse files Browse the repository at this point in the history
  • Loading branch information
aldo-expensify committed Apr 3, 2024
1 parent 861a746 commit e6ebbc2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/components/MenuItem.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import type {ImageContentFit} from 'expo-image';
import type {ForwardedRef, ReactNode} from 'react';
import React, {forwardRef, useContext, useEffect, useMemo, useRef, useState} from 'react';
import React, {forwardRef, useContext, useMemo} from 'react';
import type {GestureResponderEvent, StyleProp, TextStyle, ViewStyle} from 'react-native';
import {View} from 'react-native';
import type {AnimatedStyle} from 'react-native-reanimated';
Expand Down
42 changes: 23 additions & 19 deletions src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,6 @@ function ReportPreview({
if (TransactionUtils.isPartialMerchant(formattedMerchant ?? '')) {
formattedMerchant = null;
}
const previewSubtitle =
// Formatted merchant can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
(formattedMerchant ?? formattedDescription) ||
translate('iou.requestCount', {
count: numberOfRequests - numberOfScanningReceipts - numberOfPendingRequests,
scanningReceipts: numberOfScanningReceipts,
pendingReceipts: numberOfPendingRequests,
});

const shouldShowSubmitButton = isOpenExpenseReport && reimbursableSpend !== 0;
const shouldDisableSubmitButton = shouldShowSubmitButton && !ReportUtils.isAllowedToSubmitDraftExpenseReport(iouReport);
Expand Down Expand Up @@ -236,14 +227,23 @@ function ReportPreview({
numberOfRequests === 1 && (!!formattedMerchant || !!formattedDescription) && !(hasOnlyTransactionsWithPendingRoutes && !totalDisplaySpend);
const shouldShowSubtitle = !isScanning && (shouldShowSingleRequestMerchantOrDescription || numberOfRequests > 1);

const subtitle = previewSubtitle || moneyRequestComment;
const htmlSubtitle = useMemo(() => {
if (!subtitle || !shouldShowSubtitle) {
return '';
const {isSupportTextHtml, supportText} = useMemo(() => {
if (formattedMerchant) {
return {isSupportTextHtml: false, supportText: formattedMerchant};
}
if (formattedDescription ?? moneyRequestComment) {
const parsedSubtitle = new ExpensiMark().replace(formattedDescription ?? moneyRequestComment);
return {isSupportTextHtml: !!parsedSubtitle, supportText: parsedSubtitle ? `<muted-text>${parsedSubtitle}</muted-text>` : ''};
}
const parsedSubtitle = new ExpensiMark().replace(subtitle);
return parsedSubtitle ? `<muted-text>${parsedSubtitle}</muted-text>` : '';
}, [subtitle, shouldShowSubtitle]);
return {
isSupportTextHtml: false,
supportText: translate('iou.requestCount', {
count: numberOfRequests - numberOfScanningReceipts - numberOfPendingRequests,
scanningReceipts: numberOfScanningReceipts,
pendingReceipts: numberOfPendingRequests,
}),
};
}, [formattedMerchant, formattedDescription, moneyRequestComment, translate, numberOfRequests, numberOfScanningReceipts, numberOfPendingRequests]);

return (
<OfflineWithFeedback
Expand Down Expand Up @@ -307,10 +307,14 @@ function ReportPreview({
)}
</View>
</View>
{shouldShowSubtitle && htmlSubtitle && (
{shouldShowSubtitle && supportText && (
<View style={styles.flexRow}>
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.textLabelSupporting, styles.textNormal, styles.lh20]}>
<RenderHTML html={htmlSubtitle} />
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
{isSupportTextHtml ? (
<RenderHTML html={supportText} />
) : (
<Text style={[styles.textLabelSupporting, styles.textNormal, styles.lh20]}>{supportText}</Text>
)}
</View>
</View>
)}
Expand Down

0 comments on commit e6ebbc2

Please sign in to comment.