Skip to content
5 changes: 5 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,11 @@ const CONST = {
DARK: 'dark',
SYSTEM: 'system',
},
TRANSACTION: {
TYPE: {
CUSTOM_UNIT: 'customUnit',
},
},
JSON_CODE: {
SUCCESS: 200,
BAD_REQUEST: 400,
Expand Down
5 changes: 3 additions & 2 deletions src/components/ReportActionItem/MoneyRequestView.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ function MoneyRequestView({report, parentReport, shouldShowHorizontalRule, polic
receiptURIs = ReceiptUtils.getThumbnailAndImageURIs(transaction.receipt.source, transaction.filename);
}

const isDistanceRequest = TransactionUtils.isDistanceRequest(transaction);

return (
<View>
<View style={[StyleUtils.getReportWelcomeContainerStyle(isSmallScreenWidth), StyleUtils.getMinimumHeight(CONST.EMPTY_STATE_BACKGROUND.MONEY_REPORT.MIN_HEIGHT)]}>
Expand Down Expand Up @@ -162,10 +164,9 @@ function MoneyRequestView({report, parentReport, shouldShowHorizontalRule, polic
</OfflineWithFeedback>
<OfflineWithFeedback pendingAction={lodashGet(transaction, 'pendingFields.merchant') || lodashGet(transaction, 'pendingAction')}>
<MenuItemWithTopDescription
description={translate('common.merchant')}
description={isDistanceRequest ? translate('tabSelector.distance') : translate('common.merchant')}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would suggest that we move tabSelector.distance key to under common in translations because it is just a word and might be used in multiple places.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually that would break this code so we should probably not move it. We could add another entry under common but duplicating it doesn't feel right.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@arosiclair Can you please create a follow-up issue to clean this up?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done: #25722

title={transactionMerchant}
shouldShowRightIcon={false}
disabled
/>
</OfflineWithFeedback>
{shouldShowHorizontalRule && <View style={styles.reportHorizontalRule} />}
Expand Down
14 changes: 14 additions & 0 deletions src/libs/TransactionUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,19 @@ function isReceiptBeingScanned(transaction) {
return transaction.receipt.state === CONST.IOU.RECEIPT_STATE.SCANREADY || transaction.receipt.state === CONST.IOU.RECEIPT_STATE.SCANNING;
}

/**
* @param {Object} transaction
* @param {String} transaction.type
* @param {Object} [transaction.customUnit]
* @param {String} [transaction.customUnit.name]
* @returns {Boolean}
*/
function isDistanceRequest(transaction) {
const type = lodashGet(transaction, 'comment.type');
const customUnitName = lodashGet(transaction, 'comment.customUnit.name');
return type === CONST.TRANSACTION.TYPE.CUSTOM_UNIT && customUnitName === CONST.CUSTOM_UNITS.NAME_DISTANCE;
}

export {
buildOptimisticTransaction,
getUpdatedTransaction,
Expand All @@ -256,4 +269,5 @@ export {
getAllReportTransactions,
hasReceipt,
isReceiptBeingScanned,
isDistanceRequest,
};