Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class MoneyRequestConfirmationList extends Component {
addDebitCardRoute={ROUTES.IOU_SEND_ADD_DEBIT_CARD}
currency={this.props.iou.selectedCurrencyCode}
policyID={this.props.policyID}
shouldShowPaymentOptions

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.

There is no reason why we should not show options in the global send money flow

/>
) : (
<ButtonWithDropdownMenu
Expand Down
5 changes: 3 additions & 2 deletions src/components/MoneyRequestHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const MoneyRequestHeader = (props) => {
Policy.isAdminOfFreePolicy([policy]) || (ReportUtils.isMoneyRequestReport(moneyRequestReport) && lodashGet(props.session, 'email', null) === moneyRequestReport.managerEmail);
const shouldShowSettlementButton = !isSettled && !props.isSingleTransactionView && isPayer;
const bankAccountRoute = ReportUtils.getBankAccountRoute(props.chatReport);
const shouldShowPaypal = Boolean(lodashGet(props.personalDetails, [moneyRequestReport.managerEmail, 'payPalMeAddress']));
return (
<View style={[{backgroundColor: themeColors.highlightBG}, styles.pl0]}>
<HeaderWithCloseButton
Expand Down Expand Up @@ -153,7 +154,7 @@ const MoneyRequestHeader = (props) => {
<SettlementButton
currency={props.report.currency}
policyID={props.report.policyID}
shouldShowPaypal={Boolean(lodashGet(props.personalDetails, [moneyRequestReport.managerEmail, 'payPalMeAddress']))}
shouldShowPaypal={shouldShowPaypal}
chatReportID={props.chatReport.reportID}
iouReport={props.report}
onPress={(paymentType) => IOU.payMoneyRequest(paymentType, props.chatReport, props.report)}
Expand All @@ -169,7 +170,7 @@ const MoneyRequestHeader = (props) => {
<SettlementButton
currency={props.report.currency}
policyID={props.report.policyID}
shouldShowPaypal={false}
shouldShowPaypal={shouldShowPaypal}

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.

this was most likely an oversight, this is same button just on mobile or web so not sure why the logic for showing paypal should be different in each

chatReportID={props.report.chatReportID}
iouReport={props.report}
onPress={(paymentType) => IOU.payMoneyRequest(paymentType, props.chatReport, props.report)}
Expand Down
10 changes: 9 additions & 1 deletion src/components/ReportActionItem/IOUPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ const IOUPreview = (props) => {
showContextMenuForReport(event, props.contextMenuAnchor, props.chatReportID, props.action, props.checkIfContextMenuActive);
};

const getPreviewHeaderText = () => {
if (props.isBillSplit) {
return props.translate('iou.split');
}

return `${props.translate('iou.cash')}${!props.iouReport.hasOutstandingIOU ? ` • ${props.translate('iou.settledExpensify')}` : ''}`;
};

const childContainer = (
<View>
<OfflineWithFeedback
Expand All @@ -174,7 +182,7 @@ const IOUPreview = (props) => {
<View style={[styles.iouPreviewBox, ...props.containerStyles]}>
<View style={[styles.flexRow]}>
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
<Text style={[styles.textLabelSupporting, styles.lh16]}>{props.isBillSplit ? props.translate('iou.split') : props.translate('iou.cash')}</Text>
<Text style={[styles.textLabelSupporting, styles.lh16]}>{getPreviewHeaderText()}</Text>
{Boolean(getSettledMessage()) && (
<>
<Icon
Expand Down
48 changes: 43 additions & 5 deletions src/components/SettlementButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,67 @@ class SettlementButton extends React.Component {

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.

Isn't this component too big for a button? Should we split it into smaller components based on the use case?

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.

Thats a good point, I think we can however keep that consideration for its separate PR, this is addressing numerous bugs in the manual requests flow already so lets get it out

getButtonOptionsFromProps() {
const buttonOptions = [];
const isExpenseReport = ReportUtils.isExpenseReport(this.props.iouReport);
const paymentMethods = {
[CONST.IOU.PAYMENT_TYPE.EXPENSIFY]: {
text: this.props.translate('iou.settleExpensify'),
icon: Expensicons.Wallet,
value: ReportUtils.isExpenseReport(this.props.iouReport) ? CONST.IOU.PAYMENT_TYPE.VBBA : CONST.IOU.PAYMENT_TYPE.EXPENSIFY,
value: CONST.IOU.PAYMENT_TYPE.EXPENSIFY,
},
[CONST.IOU.PAYMENT_TYPE.VBBA]: {
text: this.props.translate('iou.settleExpensify'),
icon: Expensicons.Wallet,
value: CONST.IOU.PAYMENT_TYPE.VBBA,
Comment thread
Julesssss marked this conversation as resolved.
},
[CONST.IOU.PAYMENT_TYPE.PAYPAL_ME]: {
text: this.props.translate('iou.settlePaypalMe'),
icon: Expensicons.PayPal,
value: CONST.IOU.PAYMENT_TYPE.PAYPAL_ME,
},
[CONST.IOU.PAYMENT_TYPE.ELSEWHERE]: {
text: this.props.translate('iou.settleElsewhere'),
text: isExpenseReport ? this.props.translate('iou.payExpenseElsewhere') : this.props.translate('iou.settleElsewhere'),

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.

The expense report should use different text

icon: Expensicons.Cash,
value: CONST.IOU.PAYMENT_TYPE.ELSEWHERE,
},
};
if (!this.props.shouldShowPaymentOptions && this.props.nvp_lastPaymentMethod[this.props.policyID]) {
return [paymentMethods[this.props.nvp_lastPaymentMethod[this.props.policyID]]];
const canUseWallet =
!isExpenseReport && this.props.currency === CONST.CURRENCY.USD && Permissions.canUsePayWithExpensify(this.props.betas) && Permissions.canUseWallet(this.props.betas);

// To achieve the one tap pay experience we need to choose the correct payment type as default,
// if user already paid for some request or expense, let's use the last payment method or use default.
if (!this.props.shouldShowPaymentOptions) {
let paymentMethod = this.props.nvp_lastPaymentMethod[this.props.policyID];
if (!paymentMethod) {
// In case the user hasn't paid a request yet, let's default to VBBA payment type in case of expense reports
if (isExpenseReport) {
paymentMethod = CONST.IOU.PAYMENT_TYPE.VBBA;
} else if (canUseWallet) {
// If they have Wallet set up, use that payment method as default
paymentMethod = CONST.IOU.PAYMENT_TYPE.EXPENSIFY;
} else {
paymentMethod = CONST.IOU.PAYMENT_TYPE.ELSEWHERE;
}
}

// In case the last payment method has been PayPal, but this request is made in currency unsupported by Paypal, default to Elsewhere
if (paymentMethod === CONST.IOU.PAYMENT_TYPE.PAYPAL_ME && !_.includes(CONST.PAYPAL_SUPPORTED_CURRENCIES, this.props.currency)) {
paymentMethod = CONST.IOU.PAYMENT_TYPE.ELSEWHERE;
}

// In case of the settlement button in the report preview component, we do not show payment options and the label for Wallet and ACH type is simply "Pay".
return [
{
...paymentMethods[paymentMethod],
text: paymentMethod === CONST.IOU.PAYMENT_TYPE.ELSEWHERE ? this.props.translate('iou.payExpenseElsewhere') : this.props.translate('iou.pay'),
},
];
}
if (this.props.currency === CONST.CURRENCY.USD && Permissions.canUsePayWithExpensify(this.props.betas) && Permissions.canUseWallet(this.props.betas)) {
if (canUseWallet) {
buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.EXPENSIFY]);
}
if (isExpenseReport) {
buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.VBBA]);
}
if (this.props.shouldShowPaypal && _.includes(CONST.PAYPAL_SUPPORTED_CURRENCIES, this.props.currency)) {
buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.PAYPAL_ME]);
}
Expand Down
10 changes: 6 additions & 4 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,17 +343,19 @@ export default {
sendMoney: 'Send money',
pay: 'Pay',
viewDetails: 'View details',
settledExpensify: 'Settled',
settledElsewhere: 'Settled elsewhere',
settledPaypalMe: 'Settled using Paypal.me',
Comment thread
mountiny marked this conversation as resolved.
settledExpensify: 'Paid',
Comment thread
mountiny marked this conversation as resolved.
settledElsewhere: 'Paid elsewhere',
settledPaypalMe: 'Paid using Paypal.me',
Comment thread
luacmartins marked this conversation as resolved.
settleExpensify: 'Pay with Expensify',
settleElsewhere: "I'll settle up elsewhere",
payExpenseElsewhere: 'Pay elsewhere',
settlePaypalMe: 'Pay with PayPal.me',
requestAmount: ({amount}) => `request ${amount}`,
splitAmount: ({amount}) => `split ${amount}`,
amountEach: ({amount}) => `${amount} each`,
payerOwesAmount: ({payer, amount}) => `${payer} owes ${amount}`,
payerSettled: ({amount}) => `settled up ${amount}`,
payerPaidAmount: ({payer, amount}) => `${payer} paid ${amount}`,
payerSettled: ({amount}) => `paid ${amount}`,
noReimbursableExpenses: 'This report has an invalid amount',
pendingConversionMessage: "Total will update when you're back online",
threadRequestReportName: ({formattedAmount, comment}) => `${formattedAmount} request${comment ? ` for ${comment}` : ''}`,
Expand Down
4 changes: 3 additions & 1 deletion src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,14 @@ export default {
settledPaypalMe: 'Pagado con PayPal.me',
settleExpensify: 'Pagar con Expensify',
settleElsewhere: 'Voy a pagar de otra forma',
payExpenseElsewhere: 'Pagar de otra forma',
settlePaypalMe: 'Pagar con PayPal.me',
requestAmount: ({amount}) => `solicitar ${amount}`,
splitAmount: ({amount}) => `dividir ${amount}`,
amountEach: ({amount}) => `${amount} cada uno`,
payerOwesAmount: ({payer, amount}) => `${payer} debe ${amount}`,
payerSettled: ({amount}) => `pagado ${amount}`,
payerPaidAmount: ({payer, amount}) => `${payer} pagó ${amount}`,
payerSettled: ({amount}) => `pagó ${amount}`,
noReimbursableExpenses: 'El monto de este informe es inválido',
pendingConversionMessage: 'El total se actualizará cuando estés online',
threadRequestReportName: ({formattedAmount, comment}) => `Solicitud de ${formattedAmount}${comment ? ` para ${comment}` : ''}`,
Expand Down
11 changes: 4 additions & 7 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ function getMoneyRequestReportName(report) {
const formattedAmount = CurrencyUtils.convertToDisplayString(getMoneyRequestTotal(report), report.currency);
const payerName = isExpenseReport(report) ? getPolicyName(report) : getDisplayNameForParticipant(report.managerEmail);

return Localize.translateLocal('iou.payerOwesAmount', {payer: payerName, amount: formattedAmount});
return Localize.translateLocal(report.hasOutstandingIOU ? 'iou.payerOwesAmount' : 'iou.payerPaidAmount', {payer: payerName, amount: formattedAmount});
}

/**
Expand Down Expand Up @@ -1254,9 +1254,6 @@ function getIOUReportActionMessage(type, total, comment, currency, paymentType =
const amount = NumberFormatUtils.format(preferredLocale, total / 100, {style: 'currency', currency});
let paymentMethodMessage;
switch (paymentType) {
case CONST.IOU.PAYMENT_TYPE.EXPENSIFY:
paymentMethodMessage = '!';
break;
case CONST.IOU.PAYMENT_TYPE.ELSEWHERE:
paymentMethodMessage = ' elsewhere';
break;
Expand All @@ -1279,7 +1276,7 @@ function getIOUReportActionMessage(type, total, comment, currency, paymentType =
iouMessage = `deleted the ${amount} request${comment && ` for ${comment}`}`;
break;
case CONST.IOU.REPORT_ACTION_TYPE.PAY:
iouMessage = isSettlingUp ? `settled up ${amount}${paymentMethodMessage}` : `sent ${amount}${comment && ` for ${comment}`}${paymentMethodMessage}`;
iouMessage = isSettlingUp ? `paid ${amount}${paymentMethodMessage}` : `sent ${amount}${comment && ` for ${comment}`}${paymentMethodMessage}`;
Comment thread
mountiny marked this conversation as resolved.
break;
default:
break;
Expand Down Expand Up @@ -2010,8 +2007,8 @@ function canRequestMoney(report) {
* @returns {Array}
*/
function getMoneyRequestOptions(report, reportParticipants, betas) {
// In the transaction thread, we do not allow any new money requests
if (ReportActionsUtils.isTransactionThread(ReportActionsUtils.getParentReportAction(report))) {
// In any thread, we do not allow any new money requests yet
if (isThread(report)) {

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.

currently we dont handle creating requests in threads gracefully so lets prevent this option for now

return [];
}

Expand Down