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
6 changes: 0 additions & 6 deletions src/hooks/useDeleteTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type {OnyxCollection} from 'react-native-onyx';
import {deleteMoneyRequest, getIOUActionForTransactions, getIOURequestPolicyID, initSplitExpenseItemData, updateSplitTransactions} from '@libs/actions/IOU';
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
import {getOriginalMessage, isMoneyRequestAction} from '@libs/ReportActionsUtils';
import {isArchivedReport} from '@libs/ReportUtils';
import {getChildTransactions, getOriginalTransactionWithSplitInfo} from '@libs/TransactionUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -103,9 +102,6 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac
const originalTransactionIouActions = getIOUActionForTransactions([transactionID], report?.reportID);
const iouReportID = isMoneyRequestAction(originalTransactionIouActions.at(0)) ? getOriginalMessage(originalTransactionIouActions.at(0))?.IOUReportID : undefined;
const iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`];
const reportNameValuePairs = allReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${iouReportID}`];
const isChatIOUReportArchived = isArchivedReport(reportNameValuePairs);
const chatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${iouReport?.chatReportID}`];
const policyRecentlyUsedCategories =
allPolicyRecentlyUsedCategories?.[
`${ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_CATEGORIES}${getNonEmptyStringOnyxID(getIOURequestPolicyID(originalTransaction, report))}`
Expand All @@ -124,9 +120,7 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac
policy,
policyRecentlyUsedCategories,
iouReport,
chatReport,
firstIOU: originalTransactionIouActions.at(0),
isChatReportArchived: isChatIOUReportArchived,
});
});

Expand Down
25 changes: 20 additions & 5 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@
};

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

Check warning on line 699 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 @@ -736,9 +736,7 @@
policy: OnyxTypes.Policy | undefined;
policyRecentlyUsedCategories: OnyxTypes.RecentlyUsedCategories | undefined;
iouReport: OnyxEntry<OnyxTypes.Report>;
chatReport: OnyxEntry<OnyxTypes.Report>;
firstIOU: OnyxEntry<OnyxTypes.ReportAction> | undefined;
isChatReportArchived?: boolean;
};

type ReplaceReceipt = {
Expand Down Expand Up @@ -773,13 +771,13 @@
};

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

Check warning on line 774 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),
});

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 780 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.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -793,7 +791,7 @@
});

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

Check warning on line 794 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.COLLECTION.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -802,7 +800,7 @@
});

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

Check warning on line 803 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.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -816,7 +814,7 @@
});

let allNextSteps: NonNullable<OnyxCollection<OnyxTypes.ReportNextStep>> = {};
Onyx.connect({

Check warning on line 817 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.COLLECTION.NEXT_STEP,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -825,7 +823,7 @@
});

const allPolicies: OnyxCollection<OnyxTypes.Policy> = {};
Onyx.connect({

Check warning on line 826 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.COLLECTION.POLICY,
callback: (val, key) => {
if (!key) {
Expand Down Expand Up @@ -861,14 +859,14 @@
// `allRecentlyUsedTags` was moved here temporarily from `src/libs/actions/Policy/Tag.ts` during the `Deprecate Onyx.connect` refactor.
// All uses of this variable should be replaced with `useOnyx`.
let allRecentlyUsedTags: OnyxCollection<RecentlyUsedTags> = {};
Onyx.connect({

Check warning on line 862 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.COLLECTION.POLICY_RECENTLY_USED_TAGS,
waitForCollectionCallback: true,
callback: (val) => (allRecentlyUsedTags = val),
});

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

Check warning on line 869 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.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -877,7 +875,7 @@
});

let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({

Check warning on line 878 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.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -13746,9 +13744,7 @@
policy,
policyRecentlyUsedCategories,
iouReport,
chatReport,
firstIOU,
isChatReportArchived,
}: UpdateSplitTransactionsParams) {
const transactionReport = getReportOrDraftReport(transactionData?.reportID);
const parentTransactionReport = getReportOrDraftReport(transactionReport?.parentReportID);
Expand Down Expand Up @@ -14008,7 +14004,26 @@
});

if (firstIOU) {
const {updatedReportAction, transactionThread} = prepareToCleanUpMoneyRequest(originalTransactionID, firstIOU, iouReport, chatReport, isChatReportArchived);
const updatedReportAction = {
[firstIOU.reportActionID]: {
pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
previousMessage: firstIOU.message,
message: [
{
type: 'COMMENT',
html: '',
text: '',
isEdited: true,
isDeletedParentAction: true,
},
],
originalMessage: {
IOUTransactionID: null,
},
errors: null,
},
};
const transactionThread = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${firstIOU.childReportID}`];
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${firstIOU?.childReportID}`,
Expand Down
6 changes: 1 addition & 5 deletions src/pages/iou/SplitExpensePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function SplitExpensePage({route}: SplitExpensePageProps) {
const isCard = isManagedCardTransaction(transaction);
const originalTransactionID = draftTransaction?.comment?.originalTransactionID ?? CONST.IOU.OPTIMISTIC_TRANSACTION_ID;
const iouActions = getIOUActionForTransactions([originalTransactionID], expenseReport?.reportID);
const {iouReport, chatReport, isChatIOUReportArchived} = useGetIOUReportFromReportAction(iouActions.at(0));
const {iouReport} = useGetIOUReportFromReportAction(iouActions.at(0));

const childTransactions = useMemo(() => getChildTransactions(allTransactions, allReports, transactionID), [allReports, allTransactions, transactionID]);
const splitFieldDataFromChildTransactions = useMemo(() => childTransactions.map((currentTransaction) => initSplitExpenseItemData(currentTransaction)), [childTransactions]);
Expand Down Expand Up @@ -183,9 +183,7 @@ function SplitExpensePage({route}: SplitExpensePageProps) {
policy: expenseReportPolicy,
policyRecentlyUsedCategories,
iouReport,
chatReport,
firstIOU: iouActions.at(0),
isChatReportArchived: isChatIOUReportArchived,
});
}, [
splitExpenses,
Expand All @@ -207,9 +205,7 @@ function SplitExpensePage({route}: SplitExpensePageProps) {
expenseReportPolicy,
policyRecentlyUsedCategories,
iouReport,
chatReport,
iouActions,
isChatIOUReportArchived,
splitFieldDataFromOriginalTransaction,
translate,
transactionID,
Expand Down
6 changes: 0 additions & 6 deletions tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2908,7 +2908,6 @@ describe('actions/IOU', () => {
policy: undefined,
policyRecentlyUsedCategories: [],
iouReport: expenseReport,
chatReport: expenseReport,
firstIOU: iouAction,
});

Expand Down Expand Up @@ -3010,7 +3009,6 @@ describe('actions/IOU', () => {
policy: undefined,
policyRecentlyUsedCategories: [],
iouReport: expenseReport,
chatReport: expenseReport,
firstIOU: undefined,
});

Expand Down Expand Up @@ -3125,7 +3123,6 @@ describe('actions/IOU', () => {
policy: undefined,
policyRecentlyUsedCategories: [],
iouReport: expenseReport,
chatReport,
firstIOU: undefined,
});

Expand Down Expand Up @@ -7863,7 +7860,6 @@ describe('actions/IOU', () => {
policy: undefined,
policyRecentlyUsedCategories: [],
iouReport: expenseReport,
chatReport,
firstIOU: undefined,
});
await waitForBatchedUpdates();
Expand Down Expand Up @@ -8005,7 +8001,6 @@ describe('actions/IOU', () => {
policy: undefined,
policyRecentlyUsedCategories: [],
iouReport: expenseReport,
chatReport,
firstIOU: undefined,
});
await waitForBatchedUpdates();
Expand Down Expand Up @@ -8161,7 +8156,6 @@ describe('actions/IOU', () => {
policy: undefined,
policyRecentlyUsedCategories: [],
iouReport: expenseReport,
chatReport,
firstIOU: undefined,
});
await waitForBatchedUpdates();
Expand Down
Loading