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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Tab from '@userActions/Tab';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import {validTransactionDraftIDsSelector} from '@src/selectors/TransactionDraft';
import type * as OnyxTypes from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import type IconAsset from '@src/types/utils/IconAsset';
Expand All @@ -37,7 +38,7 @@ function BaseFloatingCameraButton({icon}: BaseFloatingCameraButtonProps) {
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`);
const [session] = useOnyx(ONYXKEYS.SESSION, {selector: sessionSelector});
const [allTransactionDrafts] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const reportID = useMemo(() => generateReportID(), []);
Expand Down Expand Up @@ -70,7 +71,7 @@ function BaseFloatingCameraButton({icon}: BaseFloatingCameraButtonProps) {
name: CONST.TELEMETRY.SPAN_SCAN_SHORTCUT,
op: CONST.TELEMETRY.SPAN_SCAN_SHORTCUT,
});
startMoneyRequest(CONST.IOU.TYPE.CREATE, quickActionReportID, CONST.IOU.REQUEST_TYPE.SCAN, !!policyChatForActivePolicy?.reportID, undefined, allTransactionDrafts, true);
startMoneyRequest(CONST.IOU.TYPE.CREATE, quickActionReportID, draftTransactionIDs, CONST.IOU.REQUEST_TYPE.SCAN, !!policyChatForActivePolicy?.reportID, undefined, true);
});
};

Expand Down
17 changes: 8 additions & 9 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@
}, [iouTransactionID, requestParentReportAction, transactionThreadReport?.reportID, transactionViolations]);

const [allPolicyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS);
const targetPolicyTags = defaultExpensePolicy ? (allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${defaultExpensePolicy.id}`] ?? {}) : {};

Check warning on line 774 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

The 'targetPolicyTags' conditional could make the dependencies of useCallback Hook (at line 813) change on every render. Move it inside the useCallback callback. Alternatively, wrap the initialization of 'targetPolicyTags' in its own useMemo() Hook

Check warning on line 774 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

The 'targetPolicyTags' conditional could make the dependencies of useCallback Hook (at line 813) change on every render. Move it inside the useCallback callback. Alternatively, wrap the initialization of 'targetPolicyTags' in its own useMemo() Hook

const duplicateExpenseTransaction = useCallback(
(transactionList: OnyxTypes.Transaction[]) => {
Expand Down Expand Up @@ -1041,19 +1041,18 @@

const addExpenseDropdownOptions = useMemo(
() =>
getAddExpenseDropdownOptions(
getAddExpenseDropdownOptions({
translate,
expensifyIcons,
moneyRequestReport?.reportID,
icons: expensifyIcons,
iouReportID: moneyRequestReport?.reportID,
policy,
userBillingGraceEndPeriods,
userBillingGraceEndPeriodCollection: userBillingGraceEndPeriods,
draftTransactionIDs,
amountOwed,
ownerBillingGraceEndPeriod,
undefined,
undefined,
lastDistanceExpenseType,
),
[moneyRequestReport?.reportID, policy, userBillingGraceEndPeriods, amountOwed, lastDistanceExpenseType, expensifyIcons, translate, ownerBillingGraceEndPeriod],
}),
[moneyRequestReport?.reportID, policy, userBillingGraceEndPeriods, amountOwed, lastDistanceExpenseType, expensifyIcons, translate, ownerBillingGraceEndPeriod, draftTransactionIDs],
);

const exportSubmenuOptions: Record<string, DropdownOption<string>> = useMemo(() => {
Expand Down Expand Up @@ -1783,7 +1782,7 @@
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, moneyRequestReport?.reportID);
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, moneyRequestReport?.reportID, draftTransactionIDs);
},
},
[CONST.REPORT.SECONDARY_ACTIONS.PAY]: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre
const shouldShowSplitIndicator = isExpenseSplit && (hasMultipleSplits || isReportOpen);
const [cardList] = useOnyx(ONYXKEYS.CARD_LIST);
const [transactionDrafts] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftsSelector});
const draftTransactionIDs = Object.keys(transactionDrafts ?? {});
const draftTransactionIDs = useMemo(() => Object.keys(transactionDrafts ?? {}), [transactionDrafts]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why do we need this change?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think we should use useMemo to prevent creating the new object for every re-render

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks like this is unnecessary with the new compiler now. Is there a specific reason why we need to do it manually here


const {deleteTransactions} = useDeleteTransactions({report: parentReport, reportActions: parentReportAction ? [parentReportAction] : [], policy});
const {isBetaEnabled} = usePermissions();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {findFocusedRoute, useFocusEffect} from '@react-navigation/native';
import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
import isEmpty from 'lodash/isEmpty';
import React, {memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react';
import {View} from 'react-native';
Expand Down Expand Up @@ -195,24 +196,24 @@ function MoneyRequestReportTransactionList({
const [amountOwed] = useOnyx(ONYXKEYS.NVP_PRIVATE_AMOUNT_OWED);
const [reportDetailsColumns] = useOnyx(ONYXKEYS.NVP_REPORT_DETAILS_COLUMNS);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});

const shouldShowGroupedTransactions = isExpenseReport(report) && !isIOUReport(report);

const addExpenseDropdownOptions = useMemo(
() =>
getAddExpenseDropdownOptions(
getAddExpenseDropdownOptions({
translate,
expensifyIcons,
report?.reportID,
icons: expensifyIcons,
iouReportID: report?.reportID,
policy,
userBillingGraceEndPeriodCollection,
draftTransactionIDs,
amountOwed,
ownerBillingGraceEndPeriod,
undefined,
undefined,
lastDistanceExpenseType,
),
[translate, expensifyIcons, report?.reportID, policy, userBillingGraceEndPeriodCollection, amountOwed, lastDistanceExpenseType, ownerBillingGraceEndPeriod],
}),
[translate, expensifyIcons, report?.reportID, policy, userBillingGraceEndPeriodCollection, amountOwed, lastDistanceExpenseType, ownerBillingGraceEndPeriod, draftTransactionIDs],
);

const hasPendingAction = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {openUnreportedExpense} from '@userActions/Report';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import {validTransactionDraftIDsSelector} from '@src/selectors/TransactionDraft';
import type * as OnyxTypes from '@src/types/onyx';

const minModalHeight = 380;
Expand All @@ -28,6 +29,7 @@ function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report:
const illustrations = useMemoizedLazyIllustrations(['FolderWithPapersAndWatch'] as const);
const expensifyIcons = useMemoizedLazyExpensifyIcons(['Location', 'Plus'] as const);
const [lastDistanceExpenseType] = useOnyx(ONYXKEYS.NVP_LAST_DISTANCE_EXPENSE_TYPE);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
const reportId = report.reportID;
const isReportArchived = isArchivedReport(reportNameValuePairs);
const icons = useMemoizedLazyExpensifyIcons(['ReceiptPlus']);
Expand All @@ -45,7 +47,7 @@ function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report:
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, reportId);
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, reportId, draftTransactionIDs);
},
},
{
Expand All @@ -60,7 +62,7 @@ function SearchMoneyRequestReportEmptyState({report, policy, onLayout}: {report:
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
startDistanceRequest(CONST.IOU.TYPE.SUBMIT, reportId, lastDistanceExpenseType);
startDistanceRequest(CONST.IOU.TYPE.SUBMIT, reportId, draftTransactionIDs, lastDistanceExpenseType);
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import {validTransactionDraftIDsSelector} from '@src/selectors/TransactionDraft';
import type {ReportAttributesDerivedValue, Transaction} from '@src/types/onyx';
import type {PaymentMethodType} from '@src/types/onyx/OriginalMessage';
import AccessMoneyRequestReportPreviewPlaceHolder from './AccessMoneyRequestReportPreviewPlaceHolder';
Expand Down Expand Up @@ -202,6 +203,7 @@ function MoneyRequestReportPreviewContent({
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const isDEWBetaEnabled = isBetaEnabled(CONST.BETAS.NEW_DOT_DEW);
const hasViolations = hasViolationsReportUtils(iouReport?.reportID, transactionViolations, currentUserAccountID, currentUserEmail);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});

const getCanIOUBePaid = useCallback(
(shouldShowOnlyPayElsewhere = false) =>
Expand Down Expand Up @@ -710,18 +712,19 @@ function MoneyRequestReportPreviewContent({

const addExpenseDropdownOptions = useMemo(
() =>
getAddExpenseDropdownOptions(
getAddExpenseDropdownOptions({
translate,
expensifyIcons,
iouReport?.reportID,
icons: expensifyIcons,
iouReportID: iouReport?.reportID,
policy,
userBillingGraceEndPeriods,
userBillingGraceEndPeriodCollection: userBillingGraceEndPeriods,
draftTransactionIDs,
amountOwed,
ownerBillingGraceEndPeriod,
chatReportID,
iouReport?.parentReportID,
iouRequestBackToReport: chatReportID,
unreportedExpenseBackToReport: iouReport?.parentReportID,
lastDistanceExpenseType,
),
}),
[
translate,
expensifyIcons,
Expand All @@ -733,6 +736,7 @@ function MoneyRequestReportPreviewContent({
chatReportID,
lastDistanceExpenseType,
ownerBillingGraceEndPeriod,
draftTransactionIDs,
],
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {emailSelector} from '@selectors/Session';
import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
import React, {useCallback, useMemo, useRef, useState} from 'react';
import {View} from 'react-native';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
Expand Down Expand Up @@ -48,6 +49,7 @@ function SearchFiltersBarCreateButton() {
const [allBetas] = useOnyx(ONYXKEYS.BETAS);
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
const groupPaidPoliciesWithChatEnabledSelector = useCallback((policies: OnyxCollection<OnyxTypes.Policy>) => groupPaidPoliciesWithExpenseChatEnabledSelector(policies, email), [email]);
const [groupPoliciesWithChatEnabled = CONST.EMPTY_ARRAY] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {selector: groupPaidPoliciesWithChatEnabledSelector}, [email]);
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
Expand Down Expand Up @@ -140,15 +142,15 @@ function SearchFiltersBarCreateButton() {
text: translate('iou.createExpense'),
onSelected: () =>
interceptAnonymousUser(() => {
startMoneyRequest(CONST.IOU.TYPE.CREATE, generateReportID());
startMoneyRequest(CONST.IOU.TYPE.CREATE, generateReportID(), draftTransactionIDs);
}),
},
{
icon: expensifyIcons.Location,
text: translate('iou.trackDistance'),
onSelected: () =>
interceptAnonymousUser(() => {
startDistanceRequest(CONST.IOU.TYPE.CREATE, generateReportID());
startDistanceRequest(CONST.IOU.TYPE.CREATE, generateReportID(), draftTransactionIDs);
}),
},
{
Expand Down Expand Up @@ -206,6 +208,7 @@ function SearchFiltersBarCreateButton() {
[
translate,
expensifyIcons,
draftTransactionIDs,
shouldRedirectToExpensifyClassic,
showRedirectToExpensifyClassicModal,
shouldNavigateToUpgradePath,
Expand Down
6 changes: 5 additions & 1 deletion src/components/Share/ShareTabParticipantsSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import type {Ref} from 'react';
import React from 'react';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useOnyx from '@hooks/useOnyx';
import {clearMoneyRequest} from '@libs/actions/IOU';
import {saveUnknownUserDetails} from '@libs/actions/Share';
import Navigation from '@libs/Navigation/Navigation';
import MoneyRequestParticipantsSelector from '@pages/iou/request/MoneyRequestParticipantsSelector';
import {getOptimisticChatReport, saveReportDraft} from '@userActions/Report';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type ROUTES from '@src/ROUTES';
import {validTransactionDraftIDsSelector} from '@src/selectors/TransactionDraft';

type ShareTabParticipantsSelectorProps = {
detailsPageRouteObject: typeof ROUTES.SHARE_SUBMIT_DETAILS | typeof ROUTES.SHARE_DETAILS;
Expand All @@ -20,13 +23,14 @@ type InputFocusRef = {

function ShareTabParticipantsSelectorComponent({detailsPageRouteObject, ref}: ShareTabParticipantsSelectorProps) {
const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
return (
<MoneyRequestParticipantsSelector
ref={ref}
iouType={CONST.IOU.TYPE.SUBMIT}
onParticipantsAdded={(value) => {
// clear the existing draft transaction from the previous flow to prevent the old data from being displayed
clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID);
clearMoneyRequest(CONST.IOU.OPTIMISTIC_TRANSACTION_ID, draftTransactionIDs);

const participant = value.at(0);
let reportID = participant?.reportID ?? CONST.DEFAULT_NUMBER_ID;
Expand Down
16 changes: 10 additions & 6 deletions src/hooks/useSearchTypeMenuSections.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {defaultExpensifyCardSelector} from '@selectors/Card';
import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
import {useCallback, useEffect, useMemo, useState} from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import {areAllGroupPoliciesExpenseChatDisabled} from '@libs/PolicyUtils';
Expand Down Expand Up @@ -66,6 +67,7 @@ const useSearchTypeMenuSections = (queryParams?: UseSearchTypeMenuSectionsParams
const [currentUserLoginAndAccountID] = useOnyx(ONYXKEYS.SESSION, {selector: currentUserLoginAndAccountIDSelector});
const [savedSearches] = useOnyx(ONYXKEYS.SAVED_SEARCHES);
const shouldRedirectToExpensifyClassic = useMemo(() => areAllGroupPoliciesExpenseChatDisabled(allPolicies ?? {}), [allPolicies]);
const [draftTransactionIDs] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, {selector: validTransactionDraftIDsSelector});
const [pendingReportCreation, setPendingReportCreation] = useState<{policyID: string; policyName?: string; onConfirm: (shouldDismissEmptyReportsConfirmation: boolean) => void} | null>(
null,
);
Expand Down Expand Up @@ -102,18 +104,19 @@ const useSearchTypeMenuSections = (queryParams?: UseSearchTypeMenuSectionsParams

const typeMenuSections = useMemo(
() =>
createTypeMenuSections(
createTypeMenuSections({
icons,
currentUserLoginAndAccountID?.email,
currentUserLoginAndAccountID?.accountID,
currentUserEmail: currentUserLoginAndAccountID?.email,
currentUserAccountID: currentUserLoginAndAccountID?.accountID,
cardFeedsByPolicy,
defaultCardFeed ?? defaultExpensifyCard,
allPolicies,
defaultCardFeed: defaultCardFeed ?? defaultExpensifyCard,
policies: allPolicies,
savedSearches,
isOffline,
defaultExpensifyCard,
shouldRedirectToExpensifyClassic,
),
draftTransactionIDs,
}),
[
currentUserLoginAndAccountID?.email,
currentUserLoginAndAccountID?.accountID,
Expand All @@ -125,6 +128,7 @@ const useSearchTypeMenuSections = (queryParams?: UseSearchTypeMenuSectionsParams
isOffline,
shouldRedirectToExpensifyClassic,
icons,
draftTransactionIDs,
],
);

Expand Down
43 changes: 29 additions & 14 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@
};

let conciergeReportIDOnyxConnect: OnyxEntry<string>;
Onyx.connect({

Check warning on line 1036 in src/libs/ReportUtils.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.CONCIERGE_REPORT_ID,
callback: (value) => {
conciergeReportIDOnyxConnect = value;
Expand All @@ -1041,7 +1041,7 @@
});

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({

Check warning on line 1044 in src/libs/ReportUtils.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) => {
// When signed out, val is undefined
Expand All @@ -1059,7 +1059,7 @@
let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({

Check warning on line 1062 in src/libs/ReportUtils.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) => {
if (currentUserAccountID) {
Expand All @@ -1071,7 +1071,7 @@
});

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

Check warning on line 1074 in src/libs/ReportUtils.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_DRAFT,
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
Expand All @@ -1079,7 +1079,7 @@

let allPolicies: OnyxCollection<Policy>;
let policiesArray: Policy[] = [];
Onyx.connect({

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

let allPolicyDrafts: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 1092 in src/libs/ReportUtils.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_DRAFTS,
waitForCollectionCallback: true,
callback: (value) => (allPolicyDrafts = value),
Expand All @@ -1097,7 +1097,7 @@

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

Check warning on line 1100 in src/libs/ReportUtils.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 Down Expand Up @@ -1133,7 +1133,7 @@
});

let betaConfiguration: OnyxEntry<BetaConfiguration> = {};
Onyx.connect({

Check warning on line 1136 in src/libs/ReportUtils.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.BETA_CONFIGURATION,
callback: (value) => (betaConfiguration = value ?? {}),
});
Expand Down Expand Up @@ -2994,18 +2994,33 @@
* @param backToReport - The report to return to after adding an expense
* @returns The dropdown options for the add expense button
*/
function getAddExpenseDropdownOptions(
translate: LocalizedTranslate,
icons: Record<'Location' | 'ReceiptPlus', IconAsset>,
iouReportID: string | undefined,
policy: OnyxEntry<Policy>,
userBillingGraceEndPeriodCollection: OnyxCollection<BillingGraceEndPeriod>,
amountOwed: OnyxEntry<number>,
ownerBillingGraceEndPeriod: OnyxEntry<number>,
iouRequestBackToReport?: string,
unreportedExpenseBackToReport?: string,
lastDistanceExpenseType?: IOURequestType,
): Array<DropdownOption<ValueOf<typeof CONST.REPORT.ADD_EXPENSE_OPTIONS>>> {
type GetAddExpenseDropdownOptionsParams = {
translate: LocalizedTranslate;
icons: Record<'Location' | 'ReceiptPlus', IconAsset>;
iouReportID: string | undefined;
policy: OnyxEntry<Policy>;
userBillingGraceEndPeriodCollection: OnyxCollection<BillingGraceEndPeriod>;
draftTransactionIDs: string[] | undefined;
amountOwed: OnyxEntry<number>;
ownerBillingGraceEndPeriod: OnyxEntry<number>;
iouRequestBackToReport?: string;
unreportedExpenseBackToReport?: string;
lastDistanceExpenseType?: IOURequestType;
};

function getAddExpenseDropdownOptions({
translate,
icons,
iouReportID,
policy,
userBillingGraceEndPeriodCollection,
draftTransactionIDs,
amountOwed,
ownerBillingGraceEndPeriod,
iouRequestBackToReport,
unreportedExpenseBackToReport,
lastDistanceExpenseType,
}: GetAddExpenseDropdownOptionsParams): Array<DropdownOption<ValueOf<typeof CONST.REPORT.ADD_EXPENSE_OPTIONS>>> {
return [
{
value: CONST.REPORT.ADD_EXPENSE_OPTIONS.CREATE_NEW_EXPENSE,
Expand All @@ -3024,7 +3039,7 @@
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, iouReportID, undefined, false, iouRequestBackToReport);
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, iouReportID, draftTransactionIDs, undefined, false, iouRequestBackToReport);
},
},
{
Expand All @@ -3040,7 +3055,7 @@
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
startDistanceRequest(CONST.IOU.TYPE.SUBMIT, iouReportID, lastDistanceExpenseType, false, iouRequestBackToReport);
startDistanceRequest(CONST.IOU.TYPE.SUBMIT, iouReportID, draftTransactionIDs, lastDistanceExpenseType, false, iouRequestBackToReport);
},
},
{
Expand Down
Loading
Loading