From 820b50ce6dbda921845b7a961b8e9ecf9c183a3f Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Wed, 13 Dec 2023 21:07:31 +0100 Subject: [PATCH 1/3] Also VBBA is paid via expensify --- src/components/ReportActionItem/MoneyRequestPreview.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index 210a0575a310..4c7f171e3e58 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -183,6 +183,7 @@ function MoneyRequestPreview(props) { } switch (lodashGet(props.action, 'originalMessage.paymentType', '')) { case CONST.IOU.PAYMENT_TYPE.EXPENSIFY: + case CONST.IOU.PAYMENT_TYPE.VBBA: return props.translate('iou.settledExpensify'); default: return props.translate('iou.settledElsewhere'); From 4db49a7d7a2c333f0112c9f640f4562959add446 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Wed, 13 Dec 2023 22:06:18 +0100 Subject: [PATCH 2/3] Use Paid in money request preview consistently --- .../ReportActionItem/MoneyRequestPreview.js | 108 ++++++++---------- 1 file changed, 46 insertions(+), 62 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index 4c7f171e3e58..c58e33f9591c 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -14,14 +14,15 @@ import refPropTypes from '@components/refPropTypes'; import {showContextMenuForReport} from '@components/ShowContextMenuContext'; import Text from '@components/Text'; import transactionPropTypes from '@components/transactionPropTypes'; -import withLocalize, {withLocalizePropTypes} from '@components/withLocalize'; +import useLocalize from '@hooks/useLocalize'; import useWindowDimensions from '@hooks/useWindowDimensions'; -import compose from '@libs/compose'; import ControlSelection from '@libs/ControlSelection'; import * as CurrencyUtils from '@libs/CurrencyUtils'; import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import * as IOUUtils from '@libs/IOUUtils'; import * as OptionsListUtils from '@libs/OptionsListUtils'; +import iouReportPropTypes from '@pages/iouReportPropTypes'; +import reportPropTypes from '@pages/reportPropTypes'; import * as ReceiptUtils from '@libs/ReceiptUtils'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as ReportUtils from '@libs/ReportUtils'; @@ -64,20 +65,11 @@ const propTypes = { /* Onyx Props */ - /** Active IOU Report for current report */ - iouReport: PropTypes.shape({ - /** Account ID of the manager in this iou report */ - managerID: PropTypes.number, + /** chatReport associated with iouReport */ + chatReport: reportPropTypes, - /** Account ID of the creator of this iou report */ - ownerAccountID: PropTypes.number, - - /** Outstanding amount in cents of this transaction */ - total: PropTypes.number, - - /** Currency of outstanding amount of this transaction */ - currency: PropTypes.string, - }), + /** IOU report data object */ + iouReport: iouReportPropTypes, /** True if this is this IOU is a split instead of a 1:1 request */ isBillSplit: PropTypes.bool.isRequired, @@ -113,7 +105,6 @@ const propTypes = { /** Whether a message is a whisper */ isWhisper: PropTypes.bool, - ...withLocalizePropTypes, }; const defaultProps = { @@ -124,6 +115,7 @@ const defaultProps = { checkIfContextMenuActive: () => {}, containerStyles: [], walletTerms: {}, + chatReport: {}, isHovered: false, personalDetails: {}, session: { @@ -138,6 +130,7 @@ function MoneyRequestPreview(props) { const theme = useTheme(); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); + const {translate} = useLocalize(); const {isSmallScreenWidth, windowWidth} = useWindowDimensions(); if (_.isEmpty(props.iouReport) && !props.isBillSplit) { @@ -179,15 +172,9 @@ function MoneyRequestPreview(props) { const getSettledMessage = () => { if (isExpensifyCardTransaction) { - return props.translate('common.done'); - } - switch (lodashGet(props.action, 'originalMessage.paymentType', '')) { - case CONST.IOU.PAYMENT_TYPE.EXPENSIFY: - case CONST.IOU.PAYMENT_TYPE.VBBA: - return props.translate('iou.settledExpensify'); - default: - return props.translate('iou.settledElsewhere'); + return translate('common.done'); } + return translate('iou.settledExpensify'); }; const showContextMenu = (event) => { @@ -196,43 +183,43 @@ function MoneyRequestPreview(props) { const getPreviewHeaderText = () => { if (isDistanceRequest) { - return props.translate('common.distance'); + return translate('common.distance'); } if (isScanning) { - return props.translate('common.receipt'); + return translate('common.receipt'); } if (props.isBillSplit) { - return props.translate('iou.split'); + return translate('iou.split'); } if (isExpensifyCardTransaction) { - let message = props.translate('iou.card'); + let message = translate('iou.card'); if (TransactionUtils.isPending(props.transaction)) { - message += ` • ${props.translate('iou.pending')}`; + message += ` • ${translate('iou.pending')}`; } return message; } - let message = props.translate('iou.cash'); + let message = translate('iou.cash'); if (ReportUtils.isGroupPolicyExpenseReport(props.iouReport) && ReportUtils.isReportApproved(props.iouReport) && !ReportUtils.isSettled(props.iouReport)) { - message += ` • ${props.translate('iou.approved')}`; + message += ` • ${translate('iou.approved')}`; } else if (props.iouReport.isWaitingOnBankAccount) { - message += ` • ${props.translate('iou.pending')}`; + message += ` • ${translate('iou.pending')}`; } else if (props.iouReport.isCancelledIOU) { - message += ` • ${props.translate('iou.canceled')}`; + message += ` • ${translate('iou.canceled')}`; } return message; }; const getDisplayAmountText = () => { if (isDistanceRequest) { - return requestAmount && !hasPendingWaypoints ? CurrencyUtils.convertToDisplayString(requestAmount, props.transaction.currency) : props.translate('common.tbd'); + return requestAmount && !hasPendingWaypoints ? CurrencyUtils.convertToDisplayString(requestAmount, props.transaction.currency) : translate('common.tbd'); } if (isScanning) { - return props.translate('iou.receiptScanning'); + return translate('iou.receiptScanning'); } if (TransactionUtils.hasMissingSmartscanFields(props.transaction)) { @@ -332,14 +319,14 @@ function MoneyRequestPreview(props) { {shouldShowMerchant && !props.isBillSplit && ( - {hasPendingWaypoints ? requestMerchant.replace(CONST.REGEX.FIRST_SPACE, props.translate('common.tbd')) : requestMerchant} + {hasPendingWaypoints ? requestMerchant.replace(CONST.REGEX.FIRST_SPACE, translate('common.tbd')) : requestMerchant} )} {!isCurrentUserManager && props.shouldShowPendingConversionMessage && ( - {props.translate('iou.pendingConversionMessage')} + {translate('iou.pendingConversionMessage')} )} {(shouldShowDescription || (shouldShowMerchant && props.isBillSplit)) && ( {shouldShowDescription ? description : requestMerchant} @@ -347,7 +334,7 @@ function MoneyRequestPreview(props) { {props.isBillSplit && !_.isEmpty(participantAccountIDs) && requestAmount > 0 && ( - {props.translate('iou.amountEach', { + {translate('iou.amountEach', { amount: CurrencyUtils.convertToDisplayString( IOUUtils.calculateAmount(isPolicyExpenseChat ? 1 : participantAccountIDs.length - 1, requestAmount, requestCurrency), requestCurrency, @@ -375,7 +362,7 @@ function MoneyRequestPreview(props) { onPressIn={() => DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()} onPressOut={() => ControlSelection.unblock()} onLongPress={showContextMenu} - accessibilityLabel={props.isBillSplit ? props.translate('iou.split') : props.translate('iou.cash')} + accessibilityLabel={props.isBillSplit ? translate('iou.split') : translate('iou.cash')} accessibilityHint={CurrencyUtils.convertToDisplayString(requestAmount, requestCurrency)} style={[styles.moneyRequestPreviewBox, ...props.containerStyles, shouldDisableOnPress && styles.cursorDefault]} > @@ -388,26 +375,23 @@ MoneyRequestPreview.propTypes = propTypes; MoneyRequestPreview.defaultProps = defaultProps; MoneyRequestPreview.displayName = 'MoneyRequestPreview'; -export default compose( - withLocalize, - withOnyx({ - personalDetails: { - key: ONYXKEYS.PERSONAL_DETAILS_LIST, - }, - chatReport: { - key: ({chatReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`, - }, - iouReport: { - key: ({iouReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`, - }, - session: { - key: ONYXKEYS.SESSION, - }, - transaction: { - key: ({action}) => `${ONYXKEYS.COLLECTION.TRANSACTION}${(action && action.originalMessage && action.originalMessage.IOUTransactionID) || 0}`, - }, - walletTerms: { - key: ONYXKEYS.WALLET_TERMS, - }, - }), -)(MoneyRequestPreview); +export default withOnyx({ + personalDetails: { + key: ONYXKEYS.PERSONAL_DETAILS_LIST, + }, + chatReport: { + key: ({chatReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`, + }, + iouReport: { + key: ({iouReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`, + }, + session: { + key: ONYXKEYS.SESSION, + }, + transaction: { + key: ({action}) => `${ONYXKEYS.COLLECTION.TRANSACTION}${(action && action.originalMessage && action.originalMessage.IOUTransactionID) || 0}`, + }, + walletTerms: { + key: ONYXKEYS.WALLET_TERMS, + }, +})(MoneyRequestPreview); From 517f7b53c58efad922bfcf7559a643df90a58846 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Wed, 13 Dec 2023 23:52:37 +0100 Subject: [PATCH 3/3] Prettier --- src/components/ReportActionItem/MoneyRequestPreview.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index 15b19846a7fe..12c6d0629370 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -24,14 +24,14 @@ import * as CurrencyUtils from '@libs/CurrencyUtils'; import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import * as IOUUtils from '@libs/IOUUtils'; import * as OptionsListUtils from '@libs/OptionsListUtils'; -import iouReportPropTypes from '@pages/iouReportPropTypes'; -import reportPropTypes from '@pages/reportPropTypes'; import * as ReceiptUtils from '@libs/ReceiptUtils'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as ReportUtils from '@libs/ReportUtils'; import * as TransactionUtils from '@libs/TransactionUtils'; import walletTermsPropTypes from '@pages/EnablePayments/walletTermsPropTypes'; import reportActionPropTypes from '@pages/home/report/reportActionPropTypes'; +import iouReportPropTypes from '@pages/iouReportPropTypes'; +import reportPropTypes from '@pages/reportPropTypes'; import * as PaymentMethods from '@userActions/PaymentMethods'; import * as Report from '@userActions/Report'; import CONST from '@src/CONST'; @@ -104,7 +104,6 @@ const propTypes = { /** Whether a message is a whisper */ isWhisper: PropTypes.bool, - }; const defaultProps = {