From 065aff13468c88bf584c4b7d776c6c543a337dd4 Mon Sep 17 00:00:00 2001 From: Vit Horacek <36083550+mountiny@users.noreply.github.com> Date: Sat, 30 Dec 2023 01:09:30 +0100 Subject: [PATCH] Merge pull request #33785 from Expensify/vit-fixMerchantRegression [CP Staging] Fix merchant saving and copy for validation (cherry picked from commit 89ee3031bfa5890e9248f10b1b1e15b8b0fec090) --- src/languages/en.ts | 2 +- src/pages/EditRequestPage.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index bc4cec483d5f..3e53b2c69513 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -618,7 +618,7 @@ export default { genericSmartscanFailureMessage: 'Transaction is missing fields', atLeastTwoDifferentWaypoints: 'Please enter at least two different addresses', splitBillMultipleParticipantsErrorMessage: 'Split bill is only allowed between a single workspace or individual users. Please update your selection.', - invalidMerchant: 'Please enter a corrent merchant.', + invalidMerchant: 'Please enter a correct merchant.', }, waitingOnEnabledWallet: ({submitterDisplayName}: WaitingOnBankAccountParams) => `Started settling up, payment is held until ${submitterDisplayName} enables their Wallet`, enableWallet: 'Enable Wallet', diff --git a/src/pages/EditRequestPage.js b/src/pages/EditRequestPage.js index 470f45437f2e..fe2d28b6c0ef 100644 --- a/src/pages/EditRequestPage.js +++ b/src/pages/EditRequestPage.js @@ -195,17 +195,21 @@ function EditRequestPage({report, route, parentReport, policyCategories, policyT defaultMerchant={transactionMerchant} isPolicyExpenseChat={isPolicyExpenseChat} onSubmit={(transactionChanges) => { + const newTrimmedMerchant = transactionChanges.merchant.trim(); + // In case the merchant hasn't been changed, do not make the API request. - if (transactionChanges.merchant.trim() === transactionMerchant) { + // In case the merchant has been set to empty string while current merchant is partial, do nothing too. + if (newTrimmedMerchant === transactionMerchant || (newTrimmedMerchant === '' && transactionMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT)) { Navigation.dismissModal(); return; } + // This is possible only in case of IOU requests. - if (transactionChanges.merchant.trim() === '') { + if (newTrimmedMerchant === '') { editMoneyRequest({merchant: CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT}); return; } - editMoneyRequest({merchant: transactionChanges.merchant.trim()}); + editMoneyRequest({merchant: newTrimmedMerchant}); }} /> );