Skip to content

Commit fe0cbdb

Browse files
authored
Merge pull request Expensify#69492 from nkdengineer/fix/67644
Fix imported transactions are displayed as skeleton loader
2 parents f05f7b7 + 190d62d commit fe0cbdb

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/libs/actions/OnyxDerived/configs/reportTransactionsAndViolations.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
44
import type {TransactionViolation} from '@src/types/onyx';
55

66
let previousViolations: OnyxCollection<TransactionViolation[]> = {};
7+
const transactionReportIDMapping: Record<string, string> = {};
78

89
const transactionToReportIDMap: Record<string, string> = {};
910

@@ -34,11 +35,18 @@ export default createOnyxDerivedValueConfig({
3435
const reportID = transaction?.reportID;
3536

3637
// If the reportID of the transaction has changed (e.g. the transaction was split into multiple reports), we need to delete the transaction from the previous reportID and the violations from the previous reportID
37-
const previousReportID = transactionToReportIDMap[transactionKey];
38+
const previousReportID = transactionReportIDMapping[transactionKey];
39+
3840
if (previousReportID && previousReportID !== reportID && reportTransactionsAndViolations[previousReportID]) {
3941
delete reportTransactionsAndViolations[previousReportID].transactions[transactionKey];
4042
const transactionID = transactionKey.replace(ONYXKEYS.COLLECTION.TRANSACTION, '');
41-
delete reportTransactionsAndViolations[previousReportID].violations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`];
43+
if (transactionID) {
44+
delete reportTransactionsAndViolations[previousReportID].violations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`];
45+
}
46+
}
47+
48+
if (!transaction && transactionReportIDMapping[transactionKey]) {
49+
delete transactionReportIDMapping[transactionKey];
4250
}
4351

4452
if (!reportID) {
@@ -69,7 +77,7 @@ export default createOnyxDerivedValueConfig({
6977
}
7078

7179
reportTransactionsAndViolations[reportID].transactions[transactionKey] = transaction;
72-
transactionToReportIDMap[transactionKey] = reportID;
80+
transactionReportIDMapping[transactionKey] = reportID;
7381
}
7482

7583
previousViolations = violations;

0 commit comments

Comments
 (0)