Skip to content

Commit 5c9a614

Browse files
authored
Merge pull request Expensify#66030 from getusha/fix-blockers
fix: regressions after pay button standardization
2 parents f9a179e + 39080f9 commit 5c9a614

4 files changed

Lines changed: 24 additions & 20 deletions

File tree

src/components/KYCWall/BaseKYCWall.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ function KYCWall({
228228
}
229229

230230
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
231-
if (paymentMethod || policy) {
231+
if ((paymentMethod || policy) && !hasActivatedWallet) {
232232
setShouldShowAddPaymentMenu(false);
233233
selectPaymentMethod(paymentMethod, policy);
234234
return;

src/components/SettlementButton/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function SettlementButton({
123123
const hasMultiplePolicies = !isExpenseReport && activeAdminPolicies.length > 1;
124124
const lastPaymentMethodRef = useRef(lastPaymentMethod);
125125
const formattedPaymentMethods = formatPaymentMethods(bankAccountList, fundList, styles);
126-
const hasIntentToPay = formattedPaymentMethods.length === 1 && !lastPaymentMethod;
126+
const hasIntentToPay = ((formattedPaymentMethods.length === 1 && isIOUReport(iouReport)) || !!policy?.achAccount) && !lastPaymentMethod;
127127

128128
useEffect(() => {
129129
if (isLoadingLastPaymentMethod) {
@@ -262,7 +262,7 @@ function SettlementButton({
262262
if (personalBankAccountList.length && canUsePersonalBankAccount) {
263263
buttonOptions.push({
264264
text: translate('iou.settleWallet', {formattedAmount: ''}),
265-
value: CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT,
265+
value: CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT,
266266
icon: Expensicons.Wallet,
267267
});
268268
} else if (canUsePersonalBankAccount) {
@@ -293,7 +293,7 @@ function SettlementButton({
293293
activeAdminPolicies.forEach((activePolicy) => {
294294
const policyName = activePolicy.name;
295295
buttonOptions.push({
296-
text: translate('iou.payWithPolicy', {policyName: truncate(policyName, {length: 20}), formattedAmount: ''}),
296+
text: translate('iou.payWithPolicy', {policyName: truncate(policyName, {length: CONST.ADDITIONAL_ALLOWED_CHARACTERS}), formattedAmount: ''}),
297297
icon: Expensicons.Building,
298298
value: activePolicy.id,
299299
shouldUpdateSelectedIndex: false,
@@ -535,7 +535,7 @@ function SettlementButton({
535535
};
536536

537537
const customText = getCustomText();
538-
const secondaryText = getSecondaryText();
538+
const secondaryText = truncate(getSecondaryText(), {length: CONST.FORM_CHARACTER_LIMIT});
539539

540540
const defaultSelectedIndex = paymentButtonOptions.findIndex((paymentOption) => {
541541
if (lastPaymentMethod === CONST.IOU.PAYMENT_TYPE.ELSEWHERE) {

src/languages/params.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ type WorkspacesListRouteParams = {
142142
};
143143

144144
type BusinessBankAccountParams = {
145-
amount: string;
146-
last4Digits: string;
145+
amount?: string;
146+
last4Digits?: string;
147147
};
148148

149149
type WorkspaceRouteParams = {

src/libs/ReportUtils.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4566,7 +4566,7 @@ function getReportPreviewMessage(
45664566
}
45674567

45684568
const containsNonReimbursable = hasNonReimbursableTransactions(report.reportID);
4569-
const {totalDisplaySpend: totalAmount, reimbursableSpend} = getMoneyRequestSpendBreakdown(report);
4569+
const {totalDisplaySpend: totalAmount} = getMoneyRequestSpendBreakdown(report);
45704570

45714571
const parentReport = getParentReport(report);
45724572
const policyName = getPolicyName({report: parentReport ?? report, policy});
@@ -4600,7 +4600,6 @@ function getReportPreviewMessage(
46004600

46014601
// Show Paid preview message if it's settled or if the amount is paid & stuck at receivers end for only chat reports.
46024602
if (isSettled(report.reportID) || (report.isWaitingOnBankAccount && isPreviewMessageForParentChatReport)) {
4603-
const formattedReimbursableAmount = convertToDisplayString(reimbursableSpend, report.currency);
46044603
// A settled report preview message can come in three formats "paid ... elsewhere" or "paid ... with Expensify"
46054604
let translatePhraseKey: TranslationPaths = 'iou.paidElsewhere';
46064605
if (isPreviewMessageForParentChatReport) {
@@ -4626,7 +4625,7 @@ function getReportPreviewMessage(
46264625
const payerDisplayName = isPreviewMessageForParentChatReport ? payerName : actualPayerName;
46274626

46284627
return translateLocal(translatePhraseKey, {
4629-
amount: formattedReimbursableAmount,
4628+
amount: '',
46304629
payer: payerDisplayName ?? '',
46314630
last4Digits: reportPolicy?.achAccount?.accountNumber?.slice(-4) ?? '',
46324631
});
@@ -5141,11 +5140,20 @@ function getReportNameInternal({
51415140

51425141
if (isMoneyRequestAction(parentReportAction)) {
51435142
const originalMessage = getOriginalMessage(parentReportAction);
5143+
const reportPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];
5144+
const last4Digits = reportPolicy?.achAccount?.accountNumber.slice(-4) ?? '';
5145+
51445146
if (originalMessage?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) {
51455147
if (originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.ELSEWHERE) {
51465148
return translateLocal('iou.paidElsewhere');
51475149
}
5148-
if (originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.VBBA || originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) {
5150+
if (originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.VBBA) {
5151+
if (originalMessage.automaticAction) {
5152+
return translateLocal('iou.automaticallyPaidWithBusinessBankAccount', {last4Digits});
5153+
}
5154+
return translateLocal('iou.businessBankAccount', {last4Digits});
5155+
}
5156+
if (originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) {
51495157
if (originalMessage.automaticAction) {
51505158
return translateLocal('iou.automaticallyPaidWithExpensify');
51515159
}
@@ -9211,12 +9219,6 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry<ReportAction>,
92119219

92129220
let translationKey: TranslationPaths;
92139221
if (originalMessage?.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) {
9214-
// The `REPORT_ACTION_TYPE.PAY` action type is used for both fulfilling existing requests and sending money. To
9215-
// differentiate between these two scenarios, we check if the `originalMessage` contains the `IOUDetails`
9216-
// property. If it does, it indicates that this is a 'Pay someone' action.
9217-
const {amount, currency} = originalMessage?.IOUDetails ?? originalMessage ?? {};
9218-
const formattedAmount = convertToDisplayString(Math.abs(amount), currency) ?? '';
9219-
92209222
const reportPolicy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`];
92219223
const last4Digits = reportPolicy?.achAccount?.accountNumber.slice(-4) ?? '';
92229224

@@ -9227,19 +9229,21 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry<ReportAction>,
92279229
case CONST.IOU.PAYMENT_TYPE.EXPENSIFY:
92289230
case CONST.IOU.PAYMENT_TYPE.VBBA:
92299231
if (isInvoice) {
9230-
return translateLocal(payAsBusiness ? 'iou.settleInvoiceBusiness' : 'iou.settleInvoicePersonal', {amount: formattedAmount, last4Digits});
9232+
return translateLocal(payAsBusiness ? 'iou.settleInvoiceBusiness' : 'iou.settleInvoicePersonal', {amount: '', last4Digits});
92319233
}
92329234
translationKey = 'iou.businessBankAccount';
9233-
if (automaticAction) {
9235+
if (automaticAction && originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.EXPENSIFY) {
92349236
translationKey = 'iou.automaticallyPaidWithExpensify';
9237+
} else {
9238+
translationKey = 'iou.automaticallyPaidWithBusinessBankAccount';
92359239
}
92369240
break;
92379241
default:
92389242
translationKey = 'iou.payerPaidAmount';
92399243
break;
92409244
}
92419245

9242-
return translateLocal(translationKey, {amount: formattedAmount, payer: '', last4Digits});
9246+
return translateLocal(translationKey, {amount: '', payer: '', last4Digits});
92439247
}
92449248

92459249
const amount = getTransactionAmount(transaction, !isEmptyObject(iouReport) && isExpenseReport(iouReport)) ?? 0;

0 commit comments

Comments
 (0)