Skip to content

Commit

Permalink
Merge pull request #33785 from Expensify/vit-fixMerchantRegression
Browse files Browse the repository at this point in the history
[CP Staging] Fix merchant saving and copy for validation

(cherry picked from commit 89ee303)
  • Loading branch information
mountiny authored and OSBotify committed Dec 30, 2023
1 parent d8305f2 commit 065aff1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 7 additions & 3 deletions src/pages/EditRequestPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}}
/>
);
Expand Down

0 comments on commit 065aff1

Please sign in to comment.