Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d466651
perf: remove draftTransactions collection subscriptions from expense …
BartekObudzinski Mar 9, 2026
4340f8d
fix: remove unused imports from setupSentry
BartekObudzinski Mar 9, 2026
36a691c
fix: add eslint-disable for pre-existing Onyx.connect and ref pattern…
BartekObudzinski Mar 9, 2026
9eda1f7
Revert "fix: add eslint-disable for pre-existing Onyx.connect and ref…
BartekObudzinski Mar 9, 2026
880cd54
Revert "fix: remove unused imports from setupSentry"
BartekObudzinski Mar 9, 2026
027f30a
Merge remote-tracking branch 'upstream/main' into perf/remove-draft-t…
BartekObudzinski Mar 9, 2026
ce6f991
Merge remote-tracking branch 'upstream/main' into perf/remove-draft-t…
BartekObudzinski Mar 10, 2026
e97cf17
Merge remote-tracking branch 'upstream/main' into perf/remove-draft-t…
BartekObudzinski Mar 10, 2026
fa5e3b5
perf: reduce Onyx subscriptions during expense creation mount
BartekObudzinski Mar 10, 2026
9a936b7
fix: update QuickActionNavigationTest for removed draftTransactions p…
BartekObudzinski Mar 10, 2026
f9fe4f4
fix: revert requestAnimationFrame on removeDraftTransactions
BartekObudzinski Mar 10, 2026
78187ab
refactor: pass draftTransactionIDs instead of full collection to pres…
BartekObudzinski Mar 11, 2026
c855846
Merge remote-tracking branch 'upstream/main' into perf/remove-draft-t…
BartekObudzinski Mar 11, 2026
20399ce
fix: restore pure Onyx subscriptions for violations and transaction d…
BartekObudzinski Mar 11, 2026
6e33140
fix: revert AccessOrNotFoundWrapper report prop and restore report su…
BartekObudzinski Mar 11, 2026
b22d9d6
Merge remote-tracking branch 'upstream/main' into perf/remove-draft-t…
BartekObudzinski Mar 12, 2026
6d70de1
Merge remote-tracking branch 'upstream/main' into perf/remove-draft-t…
BartekObudzinski Mar 12, 2026
99bdc4f
fix: revert conditional useOnyx keys in useShowNotFoundPageInIOUStep
BartekObudzinski Mar 12, 2026
29fe8ca
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
BartekObudzinski Mar 16, 2026
aff7b12
refactor: Import React alongside useMemo in useReceiptScanDrop hook
BartekObudzinski Mar 16, 2026
3c28125
Merge remote-tracking branch 'upstream/main' into perf/remove-draft-t…
BartekObudzinski Mar 18, 2026
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
5 changes: 3 additions & 2 deletions src/components/TestDrive/Modal/EmployeeTestDriveModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useRoute} from '@react-navigation/native';
import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
import {format} from 'date-fns';
import {Str} from 'expensify-common';
import React, {useCallback, useMemo, useState} from 'react';
Expand Down Expand Up @@ -49,8 +50,8 @@ function EmployeeTestDriveModal() {
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const personalPolicy = usePersonalPolicy();
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [draftTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT);
const hasOnlyPersonalPolicies = useMemo(() => hasOnlyPersonalPoliciesUtil(allPolicies), [allPolicies]);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});

const onBossEmailChange = useCallback((value: string) => {
setBossEmail(value);
Expand Down Expand Up @@ -86,7 +87,7 @@ function EmployeeTestDriveModal() {
currentDate,
currentUserPersonalDetails,
hasOnlyPersonalPolicies,
draftTransactions,
draftTransactionIDs,
});

setMoneyRequestReceipt(transactionID, source, filename, true, CONST.TEST_RECEIPT.FILE_TYPE, false, true);
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useReceiptScanDrop.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
import React, {useMemo} from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

This will need to be reverted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you clarify what specifically needs reverting? The change here replaces the full TRANSACTION_DRAFT collection subscription with an IDs-only selector (validTransactionDraftIDsSelector), which avoids deserializing all draft transaction objects on every render. The React import removal is safe since the project uses the automatic JSX runtime.

Copy link
Contributor

Choose a reason for hiding this comment

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

It was about the react import removal, because the app was crashing for me without it

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought it has been removed by mistake. Is it not crashing for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Works fine on my end, but restoring it just to be safe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

import {setTransactionReport} from '@libs/actions/Transaction';
import {navigateToParticipantPage} from '@libs/IOUUtils';
Expand Down Expand Up @@ -35,7 +36,7 @@ function useReceiptScanDrop() {
const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`);
const [personalPolicyID] = useOnyx(ONYXKEYS.PERSONAL_POLICY_ID);
const [personalPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${personalPolicyID}`);
const [draftTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});

// Memoize the new report ID to avoid re-generating it on every render and cause the hook to change, which leads to performance issues.
const newReportID = useMemo(() => generateReportID(), []);
Expand All @@ -52,7 +53,7 @@ function useReceiptScanDrop() {
currentDate,
currentUserPersonalDetails,
hasOnlyPersonalPolicies,
draftTransactions,
draftTransactionIDs,
});

const newReceiptFiles: ReceiptFile[] = [];
Expand Down
11 changes: 8 additions & 3 deletions src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
lastSelectedDistanceRates?: OnyxEntry<OnyxTypes.LastSelectedDistanceRates>;
currentUserPersonalDetails: CurrentUserPersonalDetails;
hasOnlyPersonalPolicies: boolean;
draftTransactions: OnyxCollection<OnyxTypes.Transaction>;
draftTransactionIDs?: string[];
};

type MoneyRequestInformation = {
Expand Down Expand Up @@ -771,7 +771,7 @@
};

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

Check warning on line 774 in src/libs/actions/IOU/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.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand Down Expand Up @@ -900,7 +900,7 @@
};

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

Check warning on line 903 in src/libs/actions/IOU/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,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -914,7 +914,7 @@
});

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

Check warning on line 917 in src/libs/actions/IOU/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_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -923,7 +923,7 @@
});

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

Check warning on line 926 in src/libs/actions/IOU/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) => {
Expand All @@ -937,7 +937,7 @@
});

let allPolicyTags: OnyxCollection<OnyxTypes.PolicyTagLists> = {};
Onyx.connect({

Check warning on line 940 in src/libs/actions/IOU/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.POLICY_TAGS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -950,7 +950,7 @@
});

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

Check warning on line 953 in src/libs/actions/IOU/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 @@ -959,7 +959,7 @@
});

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

Check warning on line 962 in src/libs/actions/IOU/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_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -969,7 +969,7 @@

let userAccountID = -1;
let currentUserEmail = '';
Onyx.connect({

Check warning on line 972 in src/libs/actions/IOU/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.SESSION,
callback: (value) => {
currentUserEmail = value?.email ?? '';
Expand All @@ -978,7 +978,7 @@
});

let deprecatedCurrentUserPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetails>;
Onyx.connect({

Check warning on line 981 in src/libs/actions/IOU/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.PERSONAL_DETAILS_LIST,
callback: (value) => {
deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined;
Expand All @@ -986,7 +986,7 @@
});

let allReportActions: OnyxCollection<OnyxTypes.ReportActions>;
Onyx.connect({

Check warning on line 989 in src/libs/actions/IOU/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_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -1262,7 +1262,7 @@
lastSelectedDistanceRates,
currentUserPersonalDetails,
hasOnlyPersonalPolicies,
draftTransactions,
draftTransactionIDs,
}: InitMoneyRequestParams) {
// Generate a brand new transactionID
const newTransactionID = CONST.IOU.OPTIMISTIC_TRANSACTION_ID;
Expand All @@ -1271,7 +1271,12 @@
const created = currentDate ?? format(new Date(), 'yyyy-MM-dd');

// We remove draft transactions created during multi scanning if there are some
removeDraftTransactions(true, draftTransactions);
if (draftTransactionIDs) {
const idsToRemove = draftTransactionIDs.filter((id) => id !== CONST.IOU.OPTIMISTIC_TRANSACTION_ID);
removeDraftTransactionsByIDs(idsToRemove);
} else {
removeDraftTransactions(true);
}

// in case we have to re-init money request, but the IOU request type is the same with the old draft transaction,
// we should keep most of the existing data by using the ONYX MERGE operation
Expand Down
6 changes: 2 additions & 4 deletions src/pages/Share/SubmitDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ function SubmitDetailsPage({
const fileName = shouldUsePreValidatedFile ? getFileName(validFilesToUpload?.uri ?? CONST.ATTACHMENT_IMAGE_DEFAULT_NAME) : getFileName(currentAttachment?.content ?? '');
const fileType = shouldUsePreValidatedFile ? (validFilesToUpload?.type ?? CONST.RECEIPT_ALLOWED_FILE_TYPES.JPEG) : (currentAttachment?.mimeType ?? '');
const [hasOnlyPersonalPolicies = false] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: hasOnlyPersonalPoliciesUtil});
const [draftTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT);

useEffect(() => {
if (!errorTitle || !errorMessage) {
return;
Expand All @@ -113,9 +111,9 @@ function SubmitDetailsPage({
currentDate,
currentUserPersonalDetails,
hasOnlyPersonalPolicies,
draftTransactions,
draftTransactionIDs,
});
// The draftTransactions can be changed if users update the expense, so we don't want to re-init the money request
// initMoneyRequest is an imported action, intentionally excluded to avoid re-initializing on every render
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [reportOrAccountID, policy, personalPolicy, report, parentReport, currentDate, currentUserPersonalDetails, hasOnlyPersonalPolicies]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
import {useCallback, useContext, useMemo, useRef} from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import useFilesValidation from '@hooks/useFilesValidation';
Expand Down Expand Up @@ -56,9 +57,9 @@ function useAttachmentUploadValidation({
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const personalPolicy = usePersonalPolicy();
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [draftTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const hasOnlyPersonalPolicies = useMemo(() => hasOnlyPersonalPoliciesUtil(allPolicies), [allPolicies]);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});

const reportAttachmentsContext = useContext(AttachmentModalContext);
const showAttachmentModalScreen = useCallback(
Expand Down Expand Up @@ -104,7 +105,7 @@ function useAttachmentUploadValidation({
currentDate,
currentUserPersonalDetails,
hasOnlyPersonalPolicies,
draftTransactions,
draftTransactionIDs,
});

for (const [index, file] of files.entries()) {
Expand Down
7 changes: 4 additions & 3 deletions src/pages/iou/request/DistanceRequestStartPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useFocusEffect} from '@react-navigation/native';
import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {Keyboard, View} from 'react-native';
import FocusTrapContainerElement from '@components/FocusTrap/FocusTrapContainerElement';
Expand Down Expand Up @@ -57,7 +58,6 @@ function DistanceRequestStartPage({
const [lastDistanceExpenseType] = useOnyx(ONYXKEYS.NVP_LAST_DISTANCE_EXPENSE_TYPE);
const isLoadingSelectedTab = isLoadingOnyxValue(selectedTabResult);
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${getNonEmptyStringOnyxID(route?.params.transactionID)}`);
const [draftTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT);
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [lastSelectedDistanceRates] = useOnyx(ONYXKEYS.NVP_LAST_SELECTED_DISTANCE_RATES);
const [currentDate] = useOnyx(ONYXKEYS.CURRENT_DATE);
Expand All @@ -67,6 +67,7 @@ function DistanceRequestStartPage({
const hasOnlyPersonalPolicies = useMemo(() => hasOnlyPersonalPoliciesUtil(allPolicies), [allPolicies]);
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const personalPolicy = usePersonalPolicy();
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});

const tabTitles = {
[CONST.IOU.TYPE.REQUEST]: translate('iou.trackDistance'),
Expand Down Expand Up @@ -120,7 +121,7 @@ function DistanceRequestStartPage({
lastSelectedDistanceRates,
currentUserPersonalDetails,
hasOnlyPersonalPolicies,
draftTransactions,
draftTransactionIDs,
});
},
[
Expand All @@ -137,7 +138,7 @@ function DistanceRequestStartPage({
lastSelectedDistanceRates,
currentUserPersonalDetails,
hasOnlyPersonalPolicies,
draftTransactions,
draftTransactionIDs,
],
);

Expand Down
18 changes: 12 additions & 6 deletions src/pages/iou/request/IOURequestStartPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {useFocusEffect} from '@react-navigation/native';
import {iouRequestPolicyCollectionSelector} from '@selectors/Policy';
import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
import {Keyboard, View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
Expand Down Expand Up @@ -46,7 +47,7 @@ import type SCREENS from '@src/SCREENS';
import type {DismissedProductTraining, SelectedTabRequest} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
import IOURequestStepAmount from './step/IOURequestStepAmount';
import {IOURequestStepAmountWithTransactionOnly} from './step/IOURequestStepAmount';
import IOURequestStepDestination from './step/IOURequestStepDestination';
import IOURequestStepDistance from './step/IOURequestStepDistance';
import IOURequestStepHours from './step/IOURequestStepHours';
Expand Down Expand Up @@ -81,6 +82,7 @@ function IOURequestStartPage({
const shouldUseTab = iouType !== CONST.IOU.TYPE.SEND && iouType !== CONST.IOU.TYPE.PAY && iouType !== CONST.IOU.TYPE.INVOICE;
const personalPolicy = usePersonalPolicy();
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);
const [reportDraft] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_DRAFT}${reportID}`);
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`);
const policy = usePolicy(report?.policyID);
const [lastSelectedTab, selectedTabResult] = useOnyx(`${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.IOU_REQUEST_TYPE}`);
Expand All @@ -95,11 +97,11 @@ function IOURequestStartPage({
});

const [lastSelectedDistanceRates] = useOnyx(ONYXKEYS.NVP_LAST_SELECTED_DISTANCE_RATES);
const [draftTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT);
const [isMultiScanEnabled, setIsMultiScanEnabled] = useState(false);
const [currentDate] = useOnyx(ONYXKEYS.CURRENT_DATE);
const {isOffline} = useNetwork();
const [hasUserSubmittedExpenseOrScannedReceipt] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING, {selector: isTestReceiptTooltipDismissedSelector});
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
const hasOnlyPersonalPolicies = useMemo(() => hasOnlyPersonalPoliciesUtil(allPolicies), [allPolicies]);

const perDiemInputRef = useRef<AnimatedTextInputRef | null>(null);
Expand Down Expand Up @@ -199,7 +201,7 @@ function IOURequestStartPage({
lastSelectedDistanceRates,
currentUserPersonalDetails,
hasOnlyPersonalPolicies,
draftTransactions,
draftTransactionIDs,
});
},
[
Expand All @@ -216,7 +218,7 @@ function IOURequestStartPage({
lastSelectedDistanceRates,
currentUserPersonalDetails,
hasOnlyPersonalPolicies,
draftTransactions,
draftTransactionIDs,
],
);

Expand Down Expand Up @@ -324,10 +326,12 @@ function IOURequestStartPage({
<TopTab.Screen name={CONST.TAB_REQUEST.MANUAL}>
{() => (
<TabScreenWithFocusTrapWrapper>
<IOURequestStepAmount
<IOURequestStepAmountWithTransactionOnly
shouldKeepUserInput
route={route}
navigation={navigation}
report={report}
reportDraft={reportDraft}
/>
</TabScreenWithFocusTrapWrapper>
)}
Expand Down Expand Up @@ -408,10 +412,12 @@ function IOURequestStartPage({
onContainerElementChanged={setActiveTabContainerElement}
style={[styles.flexColumn, styles.flex1]}
>
<IOURequestStepAmount
<IOURequestStepAmountWithTransactionOnly
route={route}
navigation={navigation}
shouldKeepUserInput
report={report}
reportDraft={reportDraft}
/>
</FocusTrapContainerElement>
)}
Expand Down
11 changes: 7 additions & 4 deletions src/pages/iou/request/step/IOURequestStepAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ function IOURequestStepAmount({
const defaultExpensePolicy = useDefaultExpensePolicy();
const personalPolicy = usePersonalPolicy();
const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED);
const {duplicateTransactions, duplicateTransactionViolations} = useDuplicateTransactionsAndViolations(transactionID ? [transactionID] : []);
const isEditing = action === CONST.IOU.ACTION.EDIT;
const {duplicateTransactions, duplicateTransactionViolations} = useDuplicateTransactionsAndViolations(isEditing && transactionID ? [transactionID] : []);
const reportAttributesDerived = useReportAttributes();
const privateIsArchivedMap = usePrivateIsArchivedMap();
const isEditing = action === CONST.IOU.ACTION.EDIT;
const isSplitBill = iouType === CONST.IOU.TYPE.SPLIT;
const isCreateAction = action === CONST.IOU.ACTION.CREATE;
const isSubmitAction = action === CONST.IOU.ACTION.SUBMIT;
Expand All @@ -130,9 +130,9 @@ function IOURequestStepAmount({
const isUnreportedDistanceExpense = isEditing && isDistanceRequest(transaction) && isExpenseUnreported(transaction);

const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const [transactionDrafts] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftsSelector});
const draftTransactionIDs = Object.keys(transactionDrafts ?? {});
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);

const currentUserAccountIDParam = currentUserPersonalDetails.accountID;
const currentUserEmailParam = currentUserPersonalDetails.login ?? '';
Expand Down Expand Up @@ -491,5 +491,8 @@ const IOURequestStepAmountWithWritableReportOrNotFound = withWritableReportOrNot
// eslint-disable-next-line rulesdir/no-negated-variables
const IOURequestStepAmountWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepAmountWithWritableReportOrNotFound, true);

// Version without withWritableReportOrNotFound, for use when parent already provides report prop
const IOURequestStepAmountWithTransactionOnly = withFullTransactionOrNotFound(IOURequestStepAmount, true);

export default IOURequestStepAmountWithFullTransactionOrNotFound;
export {isParticipantP2P};
export {isParticipantP2P, IOURequestStepAmountWithTransactionOnly};
20 changes: 0 additions & 20 deletions tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11616,7 +11616,6 @@ describe('actions/IOU', () => {
currentDate,
currentUserPersonalDetails,
hasOnlyPersonalPolicies: false,
draftTransactions: undefined,
});
})
.then(async () => {
Expand All @@ -11639,7 +11638,6 @@ describe('actions/IOU', () => {
currentDate,
currentUserPersonalDetails,
hasOnlyPersonalPolicies: false,
draftTransactions: undefined,
});
})
.then(async () => {
Expand All @@ -11663,7 +11661,6 @@ describe('actions/IOU', () => {
currentDate,
currentUserPersonalDetails,
hasOnlyPersonalPolicies: false,
draftTransactions: undefined,
});
})
.then(async () => {
Expand All @@ -11684,10 +11681,6 @@ describe('actions/IOU', () => {
// Set up an additional draft transaction
await Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${otherDraftTransactionID}`, otherDraftTransaction);

const draftTransactions = {
[`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${otherDraftTransactionID}`]: otherDraftTransaction,
};

await waitForBatchedUpdates()
.then(() => {
initMoneyRequest({
Expand All @@ -11701,7 +11694,6 @@ describe('actions/IOU', () => {
currentDate,
currentUserPersonalDetails,
hasOnlyPersonalPolicies: false,
draftTransactions,
});
})
.then(async () => {
Expand All @@ -11727,11 +11719,6 @@ describe('actions/IOU', () => {
await Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${otherDraftTransactionID}`, otherDraftTransaction);
await Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`, existingOptimisticTransaction);

const draftTransactions = {
[`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${otherDraftTransactionID}`]: otherDraftTransaction,
[`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`]: existingOptimisticTransaction,
};

await waitForBatchedUpdates()
.then(() => {
initMoneyRequest({
Expand All @@ -11745,7 +11732,6 @@ describe('actions/IOU', () => {
currentDate,
currentUserPersonalDetails,
hasOnlyPersonalPolicies: false,
draftTransactions,
});
})
.then(async () => {
Expand All @@ -11772,11 +11758,6 @@ describe('actions/IOU', () => {
await Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${draftTransactionID1}`, draftTransaction1);
await Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${draftTransactionID2}`, draftTransaction2);

const draftTransactions = {
[`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${draftTransactionID1}`]: draftTransaction1,
[`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${draftTransactionID2}`]: draftTransaction2,
};

await waitForBatchedUpdates()
.then(() => {
initMoneyRequest({
Expand All @@ -11790,7 +11771,6 @@ describe('actions/IOU', () => {
currentDate,
currentUserPersonalDetails,
hasOnlyPersonalPolicies: false,
draftTransactions,
});
})
.then(async () => {
Expand Down
Loading