Skip to content
Merged
3 changes: 3 additions & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3576,6 +3576,9 @@ const CONST = {
CARD_NAME: {
CASH: '__CASH__',
},
BANK_NAME: {
UPLOAD: 'upload',
},
CARD_LIST_THRESHOLD: 8,
DEFAULT_EXPORT_TYPE: 'default',
EXPORT_CARD_TYPES: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ import {
hasMissingSmartscanFields,
hasReservationList,
hasRoute as hasRouteTransactionUtils,
isManagedCardTransaction as isCardTransactionTransactionUtils,
isFromCreditCardImport as isCardTransactionTransactionUtils,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this unused? If it's used shouldn't we update it somewhere in this file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only need to change isManagedCardTransaction to isFromCreditCardImport, because in the file we use isCardTransactionTransactionUtils. Both functions have the same params and the same purpose, but isFromCreditCardImport enhances to check imported transaction from personal card.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change caused #81997. Replacing isManagedCardTransaction with isFromCreditCardImport (while keeping the alias isCardTransactionTransactionUtils) made the shouldShowReimbursable condition use a broader check that returns true for all card imports — including personal cards. This incorrectly hid the Reimbursable toggle for personal card transactions. The fix in #84596 uses the real isManagedCardTransaction specifically for shouldShowReimbursable, which only targets centrally managed cards.

isCategoryBeingAnalyzed,
isDistanceRequest as isDistanceRequestTransactionUtils,
isExpenseUnreported as isExpenseUnreportedTransactionUtils,
Expand Down
25 changes: 25 additions & 0 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
};

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

Check warning on line 129 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 @@ -135,7 +135,7 @@
});

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

Check warning on line 138 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) => (deprecatedAllTransactionViolations = value),
Expand Down Expand Up @@ -1134,6 +1134,30 @@
return !!transaction?.managedCard;
}

/**
* Determine whether a transaction is imported from a credit card.
* This includes managed cards (Expensify/Company cards) and personal cards imported via bank connection.
*/
function isFromCreditCardImport(transaction: OnyxEntry<Transaction>): boolean {
if (transaction?.bank === CONST.COMPANY_CARDS.BANK_NAME.UPLOAD) {
return false;
}

if (isManagedCardTransaction(transaction)) {
return true;
}

if (transaction?.cardNumber) {
return true;
}

if (transaction?.bank) {
return true;
}

return false;
}

function getCardName(transaction: OnyxEntry<Transaction>): string {
return transaction?.cardName ?? '';
}
Expand Down Expand Up @@ -2515,6 +2539,7 @@
mergeProhibitedViolations,
getOriginalAttendees,
getReportOwnerAsAttendee,
isFromCreditCardImport,
getExchangeRate,
shouldReuseInitialTransaction,
getOriginalAmountForDisplay,
Expand Down
Loading