Skip to content

[No QA] Mark getTransaction as deprecated #61879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025
Merged
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
3 changes: 3 additions & 0 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@
* Get all transaction violations of the transaction with given tranactionID.
*/
function getTransactionViolations(transactionID: string | undefined, transactionViolations: OnyxCollection<TransactionViolations> | undefined): TransactionViolations | undefined {
const transaction = getTransaction(transactionID);

Check failure on line 831 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'getTransaction' is deprecated. Get the data straight from Onyx
if (!transactionID || !transactionViolations) {
return undefined;
}
Expand Down Expand Up @@ -1021,7 +1021,7 @@
* @param checkDismissed - whether to check if the violation has already been dismissed as well
*/
function isDuplicate(transactionID: string | undefined, checkDismissed = false): boolean {
const transaction = getTransaction(transactionID);

Check failure on line 1024 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'getTransaction' is deprecated. Get the data straight from Onyx
if (!transaction) {
return false;
}
Expand Down Expand Up @@ -1111,7 +1111,7 @@
* Checks if any violations for the provided transaction are of type 'notice'
*/
function hasNoticeTypeViolation(transactionID: string | undefined, transactionViolations: TransactionViolation[] | OnyxCollection<TransactionViolation[]>, showInReview?: boolean): boolean {
const transaction = getTransaction(transactionID);

Check failure on line 1114 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'getTransaction' is deprecated. Get the data straight from Onyx
if (!doesTransactionSupportViolations(transaction)) {
return false;
}
Expand All @@ -1129,7 +1129,7 @@
* Checks if any violations for the provided transaction are of type 'warning'
*/
function hasWarningTypeViolation(transactionID: string | undefined, transactionViolations: TransactionViolation[] | OnyxCollection<TransactionViolation[]>, showInReview?: boolean): boolean {
const transaction = getTransaction(transactionID);

Check failure on line 1132 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'getTransaction' is deprecated. Get the data straight from Onyx
if (!doesTransactionSupportViolations(transaction)) {
return false;
}
Expand Down Expand Up @@ -1253,6 +1253,9 @@
return Object.values(transformedTaxRates(policy, transaction)).find((taxRate) => taxRate.code === (transaction?.taxCode ?? defaultTaxCode))?.modifiedName;
}

/**
* @deprecated Get the data straight from Onyx
*/
function getTransaction(transactionID: string | number | undefined): OnyxEntry<Transaction> {
return allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
}
Expand Down Expand Up @@ -1312,7 +1315,7 @@
}
const transactionViolations = allTransactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${reviewingTransactionID}`];
const duplicates = transactionViolations?.find((violation) => violation.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION)?.data?.duplicates ?? [];
const transactions = removeSettledAndApprovedTransactions([reviewingTransactionID, ...duplicates]).map((item) => getTransaction(item));

Check failure on line 1318 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'getTransaction' is deprecated. Get the data straight from Onyx

const fieldsToCompare: FieldsToCompare = {
merchant: ['modifiedMerchant', 'merchant'],
Expand Down Expand Up @@ -1604,7 +1607,7 @@
hasWarningTypeViolation,
isCustomUnitRateIDForP2P,
getRateID,
getTransaction,

Check failure on line 1610 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'getTransaction' is deprecated. Get the data straight from Onyx

Check failure on line 1610 in src/libs/TransactionUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'getTransaction' is deprecated. Get the data straight from Onyx
compareDuplicateTransactionFields,
getTransactionID,
buildNewTransactionAfterReviewingDuplicates,
Expand Down
Loading