Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions src/libs/DebugUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
const TRANSACTION_VIOLATION_REQUIRED_PROPERTIES: Array<keyof TransactionViolation> = ['type', 'name'] satisfies Array<keyof TransactionViolation>;

let isInFocusMode: OnyxEntry<boolean>;
Onyx.connect({

Check warning on line 91 in src/libs/DebugUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_PRIORITY_MODE,
callback: (priorityMode) => {
isInFocusMode = priorityMode === CONST.PRIORITY_MODE.GSD;
Expand All @@ -96,7 +96,7 @@
});

let transactionViolations: OnyxCollection<TransactionViolation[]>;
Onyx.connect({

Check warning on line 99 in src/libs/DebugUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -105,7 +105,7 @@
});

let betas: OnyxEntry<Beta[]>;
Onyx.connect({

Check warning on line 108 in src/libs/DebugUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.BETAS,
callback: (value) => {
betas = value;
Expand Down Expand Up @@ -951,7 +951,6 @@
case 'hasEReceipt':
case 'shouldShowOriginalAmount':
case 'managedCard':
case 'wasMerchantCleared':
return validateBoolean(value);
case 'amount':
case 'taxAmount':
Expand Down Expand Up @@ -1074,7 +1073,6 @@
inserted: CONST.RED_BRICK_ROAD_PENDING_ACTION,
accountant: CONST.RED_BRICK_ROAD_PENDING_ACTION,
splitExpenses: CONST.RED_BRICK_ROAD_PENDING_ACTION,
wasMerchantCleared: CONST.RED_BRICK_ROAD_PENDING_ACTION,
},
'string',
);
Expand Down
23 changes: 3 additions & 20 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

let allTransactions: OnyxCollection<Transaction> = {};

Onyx.connect({

Check warning on line 102 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -111,7 +111,7 @@
});

let allTransactionDrafts: OnyxCollection<Transaction> = {};
Onyx.connect({

Check warning on line 114 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -120,7 +120,7 @@
});

let allReports: OnyxCollection<Report> = {};
Onyx.connect({

Check warning on line 123 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -129,7 +129,7 @@
});

let allTransactionViolations: OnyxCollection<TransactionViolations> = {};
Onyx.connect({

Check warning on line 132 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => (allTransactionViolations = value),
Expand All @@ -137,7 +137,7 @@

let currentUserEmail = '';
let currentUserAccountID = -1;
Onyx.connect({

Check warning on line 140 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (val) => {
currentUserEmail = val?.email ?? '';
Expand Down Expand Up @@ -338,10 +338,6 @@
}

function isMerchantMissing(transaction: OnyxEntry<Transaction>) {
if (transaction?.wasMerchantCleared) {
return true;
}

if (transaction?.modifiedMerchant && transaction.modifiedMerchant !== '') {
return transaction.modifiedMerchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT;
}
Expand Down Expand Up @@ -438,10 +434,6 @@
shouldStopSmartscan = true;
}

if (Object.hasOwn(transactionChanges, 'wasMerchantCleared')) {
updatedTransaction.wasMerchantCleared = transactionChanges.wasMerchantCleared;
}

if (Object.hasOwn(transactionChanges, 'waypoints')) {
updatedTransaction.modifiedWaypoints = transactionChanges.waypoints;
updatedTransaction.isLoading = true;
Expand Down Expand Up @@ -701,12 +693,8 @@
* Return the merchant field from the transaction, return the modifiedMerchant if present.
*/
function getMerchant(transaction: OnyxInputOrEntry<Transaction>, policyParam: OnyxEntry<Policy> = undefined): string {
if (!transaction) {
return '';
}

const report = getReportOrDraftReport(transaction.reportID);
if (isDistanceRequest(transaction)) {
if (transaction && isDistanceRequest(transaction)) {
const report = getReportOrDraftReport(transaction.reportID);
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line deprecation/deprecation
const policy = policyParam ?? getPolicy(report?.policyID);
Expand All @@ -719,12 +707,7 @@
);
}
}

// Check if merchant was intentionally cleared by user (only for personal expenses)
if (transaction.wasMerchantCleared) {
return '';
}
return transaction.modifiedMerchant ? transaction.modifiedMerchant : (transaction.merchant ?? '');
return transaction?.modifiedMerchant ? transaction.modifiedMerchant : (transaction?.merchant ?? '');
}

function getMerchantOrDescription(transaction: OnyxEntry<Transaction>) {
Expand Down
6 changes: 0 additions & 6 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@
};

let allPersonalDetails: OnyxTypes.PersonalDetailsList = {};
Onyx.connect({

Check warning on line 632 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand Down Expand Up @@ -669,7 +669,7 @@
};

let allBetas: OnyxEntry<OnyxTypes.Beta[]>;
Onyx.connect({

Check warning on line 672 in src/libs/actions/IOU.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.BETAS,
callback: (value) => (allBetas = value),
});
Expand Down Expand Up @@ -4621,16 +4621,10 @@
policy: OnyxEntry<OnyxTypes.Policy>,
policyTagList: OnyxEntry<OnyxTypes.PolicyTagLists>,
policyCategories: OnyxEntry<OnyxTypes.PolicyCategories>,
wasMerchantCleared?: boolean,
) {
const transactionChanges: TransactionChanges = {
merchant: value,
};

if (wasMerchantCleared !== undefined) {
transactionChanges.wasMerchantCleared = wasMerchantCleared;
}

const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null;
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport?.parentReportID}`] ?? null;
let data: UpdateMoneyRequestData;
Expand Down
22 changes: 3 additions & 19 deletions src/pages/iou/request/step/IOURequestStepMerchant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,10 @@ function IOURequestStepMerchant({
navigateBack();
return;
}

// Check if merchant was intentionally cleared by user
const existingMerchantValue = merchant === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT ? '' : merchant;
const wasMerchantCleared = newMerchant === '' && existingMerchantValue !== '';

// Determine the merchant value to save
let merchantValue: string;
if (wasMerchantCleared) {
if (isMerchantRequired) {
return;
}
merchantValue = '';
} else {
// Fallback to PARTIAL_TRANSACTION_MERCHANT only if merchant is null or undefined
merchantValue = newMerchant ?? CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT;
}

setMoneyRequestMerchant(transactionID, merchantValue, !isEditing);
// When creating/editing an expense, newMerchant can be blank so we fall back on PARTIAL_TRANSACTION_MERCHANT
setMoneyRequestMerchant(transactionID, newMerchant || CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT, !isEditing);
if (isEditing) {
updateMoneyRequestMerchant(transactionID, reportID, merchantValue, policy, policyTags, policyCategories, wasMerchantCleared && !isMerchantRequired);
updateMoneyRequestMerchant(transactionID, reportID, newMerchant || CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT, policy, policyTags, policyCategories);
}
navigateBack();
};
Expand Down
3 changes: 0 additions & 3 deletions src/types/onyx/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,6 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback<

/** The inserted time of the transaction */
inserted?: string;

/** Whether the merchant field was intentionally cleared by the user */
wasMerchantCleared?: boolean;
},
keyof Comment | keyof TransactionCustomUnit | 'attendees'
>;
Expand Down
Loading