Skip to content

Commit 73c50d5

Browse files
authored
Merge pull request Expensify#66082 from Expensify/revert-64761-fix/63587
Revert "fix: After clearing merchant and saving it, Merchant field reverts to previous value Expensify#63587"
2 parents 4757f75 + 30042a6 commit 73c50d5

5 files changed

Lines changed: 6 additions & 50 deletions

File tree

src/libs/DebugUtils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,6 @@ function validateTransactionDraftProperty(key: keyof Transaction, value: string)
947947
case 'hasEReceipt':
948948
case 'shouldShowOriginalAmount':
949949
case 'managedCard':
950-
case 'wasMerchantCleared':
951950
return validateBoolean(value);
952951
case 'amount':
953952
case 'taxAmount':
@@ -1070,7 +1069,6 @@ function validateTransactionDraftProperty(key: keyof Transaction, value: string)
10701069
inserted: CONST.RED_BRICK_ROAD_PENDING_ACTION,
10711070
accountant: CONST.RED_BRICK_ROAD_PENDING_ACTION,
10721071
splitExpenses: CONST.RED_BRICK_ROAD_PENDING_ACTION,
1073-
wasMerchantCleared: CONST.RED_BRICK_ROAD_PENDING_ACTION,
10741072
},
10751073
'string',
10761074
);

src/libs/TransactionUtils/index.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,6 @@ function hasReceiptSource(transaction: OnyxInputOrEntry<Transaction>): boolean {
338338
}
339339

340340
function isMerchantMissing(transaction: OnyxEntry<Transaction>) {
341-
if (transaction?.wasMerchantCleared) {
342-
return true;
343-
}
344-
345341
if (transaction?.modifiedMerchant && transaction.modifiedMerchant !== '') {
346342
return transaction.modifiedMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT;
347343
}
@@ -438,10 +434,6 @@ function getUpdatedTransaction({
438434
shouldStopSmartscan = true;
439435
}
440436

441-
if (Object.hasOwn(transactionChanges, 'wasMerchantCleared')) {
442-
updatedTransaction.wasMerchantCleared = transactionChanges.wasMerchantCleared;
443-
}
444-
445437
if (Object.hasOwn(transactionChanges, 'waypoints')) {
446438
updatedTransaction.modifiedWaypoints = transactionChanges.waypoints;
447439
updatedTransaction.isLoading = true;
@@ -701,12 +693,8 @@ function isUnreportedAndHasInvalidDistanceRateTransaction(transaction: OnyxInput
701693
* Return the merchant field from the transaction, return the modifiedMerchant if present.
702694
*/
703695
function getMerchant(transaction: OnyxInputOrEntry<Transaction>, policyParam: OnyxEntry<Policy> = undefined): string {
704-
if (!transaction) {
705-
return '';
706-
}
707-
708-
const report = getReportOrDraftReport(transaction.reportID);
709-
if (isDistanceRequest(transaction)) {
696+
if (transaction && isDistanceRequest(transaction)) {
697+
const report = getReportOrDraftReport(transaction.reportID);
710698
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
711699
// eslint-disable-next-line deprecation/deprecation
712700
const policy = policyParam ?? getPolicy(report?.policyID);
@@ -719,12 +707,7 @@ function getMerchant(transaction: OnyxInputOrEntry<Transaction>, policyParam: On
719707
);
720708
}
721709
}
722-
723-
// Check if merchant was intentionally cleared by user (only for personal expenses)
724-
if (transaction.wasMerchantCleared) {
725-
return '';
726-
}
727-
return transaction.modifiedMerchant ? transaction.modifiedMerchant : (transaction.merchant ?? '');
710+
return transaction?.modifiedMerchant ? transaction.modifiedMerchant : (transaction?.merchant ?? '');
728711
}
729712

730713
function getMerchantOrDescription(transaction: OnyxEntry<Transaction>) {

src/libs/actions/IOU.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4620,16 +4620,10 @@ function updateMoneyRequestMerchant(
46204620
policy: OnyxEntry<OnyxTypes.Policy>,
46214621
policyTagList: OnyxEntry<OnyxTypes.PolicyTagLists>,
46224622
policyCategories: OnyxEntry<OnyxTypes.PolicyCategories>,
4623-
wasMerchantCleared?: boolean,
46244623
) {
46254624
const transactionChanges: TransactionChanges = {
46264625
merchant: value,
46274626
};
4628-
4629-
if (wasMerchantCleared !== undefined) {
4630-
transactionChanges.wasMerchantCleared = wasMerchantCleared;
4631-
}
4632-
46334627
const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null;
46344628
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport?.parentReportID}`] ?? null;
46354629
let data: UpdateMoneyRequestData;

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

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,26 +100,10 @@ function IOURequestStepMerchant({
100100
navigateBack();
101101
return;
102102
}
103-
104-
// Check if merchant was intentionally cleared by user
105-
const existingMerchantValue = merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT ? '' : merchant;
106-
const wasMerchantCleared = newMerchant === '' && existingMerchantValue !== '';
107-
108-
// Determine the merchant value to save
109-
let merchantValue: string;
110-
if (wasMerchantCleared) {
111-
if (isMerchantRequired) {
112-
return;
113-
}
114-
merchantValue = '';
115-
} else {
116-
// Fallback to PARTIAL_TRANSACTION_MERCHANT only if merchant is null or undefined
117-
merchantValue = newMerchant ?? CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT;
118-
}
119-
120-
setMoneyRequestMerchant(transactionID, merchantValue, !isEditing);
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);
121105
if (isEditing) {
122-
updateMoneyRequestMerchant(transactionID, reportID, merchantValue, policy, policyTags, policyCategories, wasMerchantCleared && !isMerchantRequired);
106+
updateMoneyRequestMerchant(transactionID, reportID, newMerchant || CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT, policy, policyTags, policyCategories);
123107
}
124108
navigateBack();
125109
};

src/types/onyx/Transaction.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,6 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback<
548548

549549
/** The inserted time of the transaction */
550550
inserted?: string;
551-
552-
/** Whether the merchant field was intentionally cleared by the user */
553-
wasMerchantCleared?: boolean;
554551
},
555552
keyof Comment | keyof TransactionCustomUnit | 'attendees'
556553
>;

0 commit comments

Comments
 (0)