Skip to content

Commit

Permalink
Merge pull request #34359 from rojiphil/33874-hide-none-for-merchant
Browse files Browse the repository at this point in the history
hide partial merchant name
  • Loading branch information
mountiny authored Jan 18, 2024
2 parents 4ce71ed + 9f37be5 commit ce0b4d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/ReportActionItem/ReportPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ function ReportPreview(props) {
const lastThreeTransactionsWithReceipts = transactionsWithReceipts.slice(-3);
const lastThreeReceipts = _.map(lastThreeTransactionsWithReceipts, (transaction) => ReceiptUtils.getThumbnailAndImageURIs(transaction));
let formattedMerchant = numberOfRequests === 1 && hasReceipts ? TransactionUtils.getMerchant(transactionsWithReceipts[0]) : null;
if (TransactionUtils.isPartialMerchant(formattedMerchant)) {
formattedMerchant = null;
}
const hasPendingWaypoints = formattedMerchant && hasOnlyDistanceRequests && _.every(transactionsWithReceipts, (transaction) => lodashGet(transaction, 'pendingFields.waypoints', null));
if (hasPendingWaypoints) {
formattedMerchant = formattedMerchant.replace(CONST.REGEX.FIRST_SPACE, props.translate('common.tbd'));
Expand Down Expand Up @@ -294,7 +297,7 @@ function ReportPreview(props) {
)}
</View>
</View>
{!isScanning && (numberOfRequests > 1 || hasReceipts) && (
{!isScanning && (numberOfRequests > 1 || (hasReceipts && numberOfRequests === 1 && formattedMerchant)) && (
<View style={styles.flexRow}>
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
<Text style={[styles.textLabelSupporting, styles.textNormal, styles.mb1, styles.lh20]}>{previewSubtitle || moneyRequestComment}</Text>
Expand Down
8 changes: 8 additions & 0 deletions src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ function isMerchantMissing(transaction: Transaction) {
return isMerchantEmpty && isModifiedMerchantEmpty;
}

/**
* Check if the merchant is partial i.e. `(none)`
*/
function isPartialMerchant(merchant: string): boolean {
return merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT;
}

function isAmountMissing(transaction: Transaction) {
return transaction.amount === 0 && (!transaction.modifiedAmount || transaction.modifiedAmount === 0);
}
Expand Down Expand Up @@ -573,6 +580,7 @@ export {
getWaypoints,
isAmountMissing,
isMerchantMissing,
isPartialMerchant,
isCreatedMissing,
areRequiredFieldsEmpty,
hasMissingSmartscanFields,
Expand Down

0 comments on commit ce0b4d2

Please sign in to comment.