Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function MerchantField({
const [splitDraftTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`);

const merchantValue = getMerchant(transaction);
const displayMerchantValue = isInvalidMerchantValue(merchantValue) ? '' : merchantValue;
const displayMerchantValue = !transaction?.isMerchantSet && isInvalidMerchantValue(merchantValue) ? '' : merchantValue;
const isMerchantEmpty = !displayMerchantValue;

// Determine if the merchant error should be displayed
Expand Down
14 changes: 11 additions & 3 deletions src/pages/iou/request/step/IOURequestStepMerchant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {skipNextFocusRestore} from '@libs/NavigationFocusReturn';
import {getTransactionDetails, isExpenseRequest, isPolicyExpenseChat} from '@libs/ReportUtils';
import {hasReceipt} from '@libs/TransactionUtils';
import {isInvalidMerchantValue, isValidInputLength} from '@libs/ValidationUtils';
import {setMoneyRequestMerchant} from '@userActions/IOU/MoneyRequest';
import {clearMoneyRequestMerchant, setMoneyRequestMerchant} from '@userActions/IOU/MoneyRequest';
import {setDraftSplitTransaction} from '@userActions/IOU/Split';
import {updateMoneyRequestMerchant} from '@userActions/IOU/UpdateMoneyRequest';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -123,7 +123,13 @@ function IOURequestStepMerchant({
return;
}

if (newMerchant === merchant || (newMerchant === '' && merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT)) {
if (newMerchant === '' && isInvalidMerchantValue(merchant)) {
setIsSaved(true);
shouldNavigateAfterSaveRef.current = true;
clearMoneyRequestMerchant(transactionID);
return;
}
if (newMerchant === merchant || (newMerchant === '' && isInvalidMerchantValue(merchant))) {
setIsSaved(true);
shouldNavigateAfterSaveRef.current = true;
return;
Expand All @@ -146,8 +152,10 @@ function IOURequestStepMerchant({
parentReportNextStep,
delegateAccountID,
});
} else if (!newMerchant) {
clearMoneyRequestMerchant(transactionID);
} else {
setMoneyRequestMerchant(transactionID, newMerchant || CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT, true, hasReceipt(transaction));
setMoneyRequestMerchant(transactionID, newMerchant, true, hasReceipt(transaction));
}
setIsSaved(true);
shouldNavigateAfterSaveRef.current = true;
Expand Down
Loading