Skip to content

Commit b69ad10

Browse files
committed
fix: After clearing merchant and saving it, Merchant field reverts to previous value Expensify#63587
1 parent 56d08a4 commit b69ad10

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/libs/TransactionUtils/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,15 @@ function getMerchant(transaction: OnyxInputOrEntry<Transaction>, policyParam: On
677677
toLocaleDigit(TranslationStore.getCurrentLocale(), digit),
678678
);
679679
}
680+
681+
// Check if this is a workspace expense transaction
682+
const report = getReportOrDraftReport(transaction?.reportID);
683+
const isWorkspaceExpense = report?.type === CONST.REPORT.TYPE.EXPENSE;
684+
685+
// Allow empty merchant only for personal expenses, not workspace ones
686+
if (transaction?.modifiedMerchant === '' && !isWorkspaceExpense) {
687+
return '';
688+
}
680689
return transaction?.modifiedMerchant ? transaction.modifiedMerchant : (transaction?.merchant ?? '');
681690
}
682691

src/pages/iou/request/step/IOURequestStepMerchant.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,13 @@ function IOURequestStepMerchant({
100100
navigateBack();
101101
return;
102102
}
103-
// When creating/editing an expense, newMerchant can be blank so we fall back on PARTIAL_TRANSACTION_MERCHANT
104-
setMoneyRequestMerchant(transactionID, newMerchant || CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT, !isEditing);
103+
104+
// Fallback to PARTIAL_TRANSACTION_MERCHANT only if merchant is null or undefined
105+
const merchantValue = newMerchant ?? CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT;
106+
107+
setMoneyRequestMerchant(transactionID, merchantValue, !isEditing);
105108
if (isEditing) {
106-
updateMoneyRequestMerchant(transactionID, reportID, newMerchant || CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT, policy, policyTags, policyCategories);
109+
updateMoneyRequestMerchant(transactionID, reportID, merchantValue, policy, policyTags, policyCategories);
107110
}
108111
navigateBack();
109112
};

0 commit comments

Comments
 (0)