diff --git a/src/CONST.ts b/src/CONST.ts index 666d7db19a15..6be817b6296b 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -666,6 +666,7 @@ const CONST = { TRANSACTION: { DEFAULT_MERCHANT: 'Request', UNKNOWN_MERCHANT: 'Unknown Merchant', + PARTIAL_TRANSACTION_MERCHANT: '(none)', TYPE: { CUSTOM_UNIT: 'customUnit', }, diff --git a/src/components/ReportActionItem/MoneyRequestAction.js b/src/components/ReportActionItem/MoneyRequestAction.js index bb312f85be41..3b310bb6b4fa 100644 --- a/src/components/ReportActionItem/MoneyRequestAction.js +++ b/src/components/ReportActionItem/MoneyRequestAction.js @@ -58,6 +58,9 @@ const propTypes = { network: networkPropTypes.isRequired, + /** Whether a message is a whisper */ + isWhisper: PropTypes.bool, + /** Styles to be assigned to Container */ // eslint-disable-next-line react/forbid-prop-types style: PropTypes.arrayOf(PropTypes.object), @@ -71,6 +74,7 @@ const defaultProps = { reportActions: {}, isHovered: false, style: [], + isWhisper: false, }; function MoneyRequestAction({ @@ -86,6 +90,7 @@ function MoneyRequestAction({ isHovered, network, style, + isWhisper, }) { const {translate} = useLocalize(); const isSplitBillAction = lodashGet(action, 'originalMessage.type', '') === CONST.IOU.REPORT_ACTION_TYPE.SPLIT; @@ -137,6 +142,7 @@ function MoneyRequestAction({ onPreviewPressed={onMoneyRequestPreviewPressed} containerStyles={[styles.cursorPointer, isHovered ? styles.reportPreviewBoxHoverBorder : undefined, ...style]} isHovered={isHovered} + isWhisper={isWhisper} /> ); } diff --git a/src/components/ReportActionItem/MoneyRequestPreview.js b/src/components/ReportActionItem/MoneyRequestPreview.js index 5c834a53a00e..a46205200040 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview.js +++ b/src/components/ReportActionItem/MoneyRequestPreview.js @@ -27,8 +27,6 @@ import * as CurrencyUtils from '../../libs/CurrencyUtils'; import * as IOUUtils from '../../libs/IOUUtils'; import * as ReportUtils from '../../libs/ReportUtils'; import * as TransactionUtils from '../../libs/TransactionUtils'; -import * as StyleUtils from '../../styles/StyleUtils'; -import getButtonState from '../../libs/getButtonState'; import refPropTypes from '../refPropTypes'; import PressableWithFeedback from '../Pressable/PressableWithoutFeedback'; import * as ReceiptUtils from '../../libs/ReceiptUtils'; @@ -111,6 +109,9 @@ const propTypes = { */ shouldShowPendingConversionMessage: PropTypes.bool, + /** Whether a message is a whisper */ + isWhisper: PropTypes.bool, + ...withLocalizePropTypes, }; @@ -129,6 +130,7 @@ const defaultProps = { }, transaction: {}, shouldShowPendingConversionMessage: false, + isWhisper: false, }; function MoneyRequestPreview(props) { @@ -156,6 +158,11 @@ function MoneyRequestPreview(props) { const hasFieldErrors = TransactionUtils.hasMissingSmartscanFields(props.transaction); const isDistanceRequest = TransactionUtils.isDistanceRequest(props.transaction); + // Show the merchant for IOUs and expenses only if they are custom or not related to scanning smartscan + const shouldShowMerchant = + !_.isEmpty(requestMerchant) && !props.isBillSplit && requestMerchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && requestMerchant !== CONST.TRANSACTION.DEFAULT_MERCHANT; + const shouldShowDescription = !_.isEmpty(description) && !shouldShowMerchant; + const getSettledMessage = () => { switch (lodashGet(props.action, 'originalMessage.paymentType', '')) { case CONST.IOU.PAYMENT_TYPE.PAYPAL_ME: @@ -220,7 +227,7 @@ function MoneyRequestPreview(props) { errorRowStyles={[styles.mbn1]} needsOffscreenAlphaCompositing > - + {hasReceipt && ( )} - @@ -278,7 +281,7 @@ function MoneyRequestPreview(props) { )} - {!props.isBillSplit && !_.isEmpty(requestMerchant) && ( + {shouldShowMerchant && ( {requestMerchant} @@ -288,7 +291,7 @@ function MoneyRequestPreview(props) { {!isCurrentUserManager && props.shouldShowPendingConversionMessage && ( {props.translate('iou.pendingConversionMessage')} )} - {!_.isEmpty(description) && {description}} + {shouldShowDescription && {description}} {props.isBillSplit && !_.isEmpty(participantAccountIDs) && ( diff --git a/src/components/ReportActionItem/ReportPreview.js b/src/components/ReportActionItem/ReportPreview.js index e962d4ea757b..2915e280186e 100644 --- a/src/components/ReportActionItem/ReportPreview.js +++ b/src/components/ReportActionItem/ReportPreview.js @@ -23,8 +23,6 @@ import ROUTES from '../../ROUTES'; import SettlementButton from '../SettlementButton'; import * as IOU from '../../libs/actions/IOU'; import refPropTypes from '../refPropTypes'; -import * as StyleUtils from '../../styles/StyleUtils'; -import getButtonState from '../../libs/getButtonState'; import PressableWithoutFeedback from '../Pressable/PressableWithoutFeedback'; import themeColors from '../../styles/themes/default'; import reportPropTypes from '../../pages/reportPropTypes'; @@ -89,6 +87,9 @@ const propTypes = { /** Callback for updating context menu active state, used for showing context menu */ checkIfContextMenuActive: PropTypes.func, + /** Whether a message is a whisper */ + isWhisper: PropTypes.bool, + ...withLocalizePropTypes, }; @@ -101,6 +102,7 @@ const defaultProps = { session: { accountID: null, }, + isWhisper: false, }; function ReportPreview(props) { @@ -176,7 +178,7 @@ function ReportPreview(props) { accessibilityRole="button" accessibilityLabel={props.translate('iou.viewDetails')} > - + {hasReceipts && ( ReceiptUtils.getThumbnailAndImageURIs(receipt.source, filename))} @@ -196,10 +198,6 @@ function ReportPreview(props) { fill={colors.red} /> )} - @@ -214,7 +212,7 @@ function ReportPreview(props) { )} - {hasReceipts && !isScanning && ( + {!isScanning && (numberOfRequests > 1 || hasReceipts) && ( {previewSubtitle || moneyRequestComment} diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index ff9a5ee14519..893145a8e5fa 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -124,7 +124,15 @@ function getPolicyName(report, returnEmptyIfNotFound = false, policy = undefined // Public rooms send back the policy name with the reportSummary, // since they can also be accessed by people who aren't in the workspace - return lodashGet(finalPolicy, 'name') || report.policyName || report.oldPolicyName || noPolicyFound; + const policyName = lodashGet(finalPolicy, 'name') || report.policyName || report.oldPolicyName || noPolicyFound; + + // The SBE and SAASTR policies have the user name in its name, however, we do not want to show that + if (lodashGet(finalPolicy, 'owner') === CONST.EMAIL.SBE || lodashGet(finalPolicy, 'owner') === CONST.EMAIL.SAASTR) { + const policyNameParts = policyName.split(' '); + if (!Str.isValidEmail(policyNameParts[0])) return policyName; + return policyNameParts.length > 1 ? policyNameParts.slice(1).join(' ') : policyName; + } + return policyName; } /** diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index d5d8b38bb92c..22ded971898f 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -244,10 +244,11 @@ function ReportActionItem(props) { /** * Get the content of ReportActionItem * @param {Boolean} hovered whether the ReportActionItem is hovered + * @param {Boolean} isWhisper whether the report action is a whisper * @param {Boolean} hasErrors whether the report action has any errors * @returns {Object} child component(s) */ - const renderItemContent = (hovered = false, hasErrors = false) => { + const renderItemContent = (hovered = false, isWhisper = false, hasErrors = false) => { let children; const originalMessage = lodashGet(props.action, 'originalMessage', {}); @@ -273,6 +274,7 @@ function ReportActionItem(props) { contextMenuAnchor={popoverAnchorRef} checkIfContextMenuActive={toggleContextMenuFromActiveReportAction} style={props.displayAsGroup ? [] : [styles.mt2]} + isWhisper={isWhisper} /> ); } else if (props.action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORTPREVIEW) { @@ -286,6 +288,7 @@ function ReportActionItem(props) { isHovered={hovered} contextMenuAnchor={popoverAnchorRef} checkIfContextMenuActive={toggleContextMenuFromActiveReportAction} + isWhisper={isWhisper} /> ); } else if ( @@ -447,7 +450,7 @@ function ReportActionItem(props) { * @returns {Object} report action item */ const renderReportActionItem = (hovered, isWhisper, hasErrors) => { - const content = renderItemContent(hovered || isContextMenuActive, hasErrors); + const content = renderItemContent(hovered || isContextMenuActive, isWhisper, hasErrors); if (props.draftMessage) { return {content}; diff --git a/src/styles/styles.js b/src/styles/styles.js index 7c8c12c4a6c8..f2b81484b808 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -3782,6 +3782,8 @@ const styles = { borderColor: themeColors.cardBG, borderTopLeftRadius: variables.componentBorderRadiusLarge, borderTopRightRadius: variables.componentBorderRadiusLarge, + borderBottomLeftRadius: variables.componentBorderRadiusLarge, + borderBottomRightRadius: variables.componentBorderRadiusLarge, overflow: 'hidden', height: 200, },