Skip to content

Commit

Permalink
fix: remaining IOU issues
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispader committed Jun 5, 2024
1 parent 8ba588f commit dd7e9dd
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {format} from 'date-fns';
import fastMerge from 'expensify-common/lib/fastMerge';
import Str from 'expensify-common/lib/str';
import type {OnyxCollection, OnyxEntry, OnyxInputValue, OnyxUpdate} from 'react-native-onyx';
import type {OnyxCollection, OnyxCollectionInput, OnyxEntry, OnyxInputValue, OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import ReceiptGeneric from '@assets/images/receipt-generic.png';
Expand Down Expand Up @@ -166,11 +166,11 @@ Onyx.connect({
},
});

let allReports: OnyxCollection<OnyxTypes.Report>;
let allReports: OnyxCollection<OnyxTypes.Report> | null = null;
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => (allReports = value),
callback: (value) => (allReports = value ?? null),
});

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Expand Down Expand Up @@ -2693,7 +2693,7 @@ function getUpdateMoneyRequestParams(
failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`,
value: transactionThread ?? null,
value: transactionThread,
});

return {
Expand Down Expand Up @@ -2935,8 +2935,8 @@ function updateMoneyRequestMerchant(
const transactionChanges: TransactionChanges = {
merchant: value,
};
const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`];
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport?.parentReportID}`];
const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null;
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport?.parentReportID}`] ?? null;
let data: UpdateMoneyRequestData;
if (ReportUtils.isTrackExpenseReport(transactionThreadReport) && ReportUtils.isSelfDM(parentReport)) {
data = getUpdateTrackExpenseParams(transactionID, transactionThreadReportID, transactionChanges, true, policy);
Expand Down Expand Up @@ -3023,8 +3023,8 @@ function updateMoneyRequestDistance({
waypoints,
routes,
};
const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`];
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport?.parentReportID}`];
const transactionThreadReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`] ?? null;
const parentReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReport?.parentReportID}`] ?? null;
let data: UpdateMoneyRequestData;
if (ReportUtils.isTrackExpenseReport(transactionThreadReport) && ReportUtils.isSelfDM(parentReport)) {
data = getUpdateTrackExpenseParams(transactionID, transactionThreadReportID, transactionChanges, true, policy);
Expand Down Expand Up @@ -5328,7 +5328,7 @@ function deleteMoneyRequest(transactionID: string, reportAction: OnyxTypes.Repor
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`,
value: updatedIOUReport ?? null,
value: updatedIOUReport,
},
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down

0 comments on commit dd7e9dd

Please sign in to comment.