Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show category / tag in Expense preview view #52758

Merged
merged 8 commits into from
Nov 27, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ function MoneyRequestPreviewContent({
currency: requestCurrency,
comment: requestComment,
merchant,
tag,
category,
} = useMemo<Partial<TransactionDetails>>(() => ReportUtils.getTransactionDetails(transaction) ?? {}, [transaction]);

const description = truncate(StringUtils.lineBreaksToSpaces(requestComment), {length: CONST.REQUEST_PREVIEW.MAX_LENGTH});
Expand Down Expand Up @@ -145,6 +147,7 @@ function MoneyRequestPreviewContent({
// When there are no settled transactions in duplicates, show the "Keep this one" button
const shouldShowKeepButton = !!(allDuplicates.length && duplicates.length && allDuplicates.length === duplicates.length);

const shouldShowCategoryOrTag = !!tag || !!category;
const shouldShowRBR = hasNoticeTypeViolations || hasWarningTypeViolations || hasViolations || hasFieldErrors || (!isFullySettled && !isFullyApproved && isOnHold);
const showCashOrCard = isCardTransaction ? translate('iou.card') : translate('iou.cash');
// We don't use isOnHold because it's true for duplicated transaction too and we only want to show hold message if the transaction is truly on hold
Expand Down Expand Up @@ -427,6 +430,43 @@ function MoneyRequestPreviewContent({
</View>
)}
</View>
{shouldShowCategoryOrTag && <View style={[styles.threadDividerLine, styles.ml0, styles.mr0, styles.mt1]} />}
{shouldShowCategoryOrTag && (
<View style={[styles.flexRow, styles.pt1, styles.alignItemsCenter]}>
{!!category && (
<View style={[styles.flexRow, styles.alignItemsCenter, styles.gap1, tag && styles.mw50, tag && styles.pr1, styles.flexShrink1]}>
<Icon
src={Expensicons.Folder}
height={variables.iconSizeExtraSmall}
width={variables.iconSizeExtraSmall}
fill={theme.icon}
/>
<Text
numberOfLines={1}
style={[styles.textMicroSupporting, styles.pre, styles.flexShrink1]}
>
{category}
</Text>
</View>
)}
{!!tag && (
Copy link
Contributor

Choose a reason for hiding this comment

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

coming from this issue #53454, here we’re displaying the tag name if tag value is available. However, this alone is not sufficient for display in the preview. Rooms created under a workspace with dependent tags enabled will also show the tags in the preview. That said, tags should only appear in the expense preview if the report is a policy expense chat. More details can be found here: #53454 (comment)

<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.gap1, category && styles.pl1]}>
<Icon
src={Expensicons.Tag}
height={variables.iconSizeExtraSmall}
width={variables.iconSizeExtraSmall}
fill={theme.icon}
/>
<Text
numberOfLines={1}
style={[styles.textMicroSupporting, styles.pre, styles.flexShrink1]}
>
{tag}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use getCleanedTagName here to remove the unexpected name. Ref: #53248

</Text>
</View>
)}
</View>
)}
</View>
</View>
</View>
Expand Down
Loading