Skip to content
3 changes: 3 additions & 0 deletions src/components/AddExistingExpenseFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import useDelegateAccountID from '@hooks/useDelegateAccountID';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePermissions from '@hooks/usePermissions';
Expand Down Expand Up @@ -50,6 +51,7 @@ function AddExistingExpenseFooter({selectedIds, report, reportToConfirm, reportN
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
const session = useSession();
const personalDetails = usePersonalDetails();
const delegateAccountID = useDelegateAccountID();
const personalPolicy = usePersonalPolicy();
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
Expand Down Expand Up @@ -84,6 +86,7 @@ function AddExistingExpenseFooter({selectedIds, report, reportToConfirm, reportN
personalDetails,
betas,
policyTagList: report?.policyID ? policyTagList : chatReportPolicyTagList,
delegateAccountID,
});
} else {
changeTransactionsReport({
Expand Down
3 changes: 3 additions & 0 deletions src/components/MoneyRequestHeaderSecondaryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import useConfirmModal from '@hooks/useConfirmModal';
import {useCurrencyListActions} from '@hooks/useCurrencyList';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDefaultExpensePolicy from '@hooks/useDefaultExpensePolicy';
import useDelegateAccountID from '@hooks/useDelegateAccountID';
import useDeleteTransactions from '@hooks/useDeleteTransactions';
import useDuplicateTransactionsAndViolations from '@hooks/useDuplicateTransactionsAndViolations';
import useEnvironment from '@hooks/useEnvironment';
Expand Down Expand Up @@ -110,6 +111,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
const theme = useTheme();
const {translate, localeCompare} = useLocalize();
const {login: currentUserLogin, accountID, localCurrencyCode} = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();
const personalDetails = usePersonalDetails();

const expensifyIcons = useMemoizedLazyExpensifyIcons([
Expand Down Expand Up @@ -261,6 +263,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
targetPolicyTags,
currentUser: {accountID, email: currentUserLogin ?? ''},
currentUserLocalCurrency: localCurrencyCode ?? CONST.CURRENCY.USD,
delegateAccountID,
policyTagList,
});
}
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/useBulkDuplicateAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {validTransactionDraftsSelector} from '@selectors/TransactionDraft';

import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
import useDefaultExpensePolicy from './useDefaultExpensePolicy';
import useDelegateAccountID from './useDelegateAccountID';
import useMoneyRequestPolicyTagsForReport from './useMoneyRequestPolicyTagsForReport';
import useOnyx from './useOnyx';
import usePermissions from './usePermissions';
Expand All @@ -33,6 +34,7 @@ type UseBulkDuplicateActionParams = {
*/
function useBulkDuplicateAction({selectedTransactionsKeys, allTransactions, allReports, searchData, onAfterDuplicate}: UseBulkDuplicateActionParams) {
const {accountID, login: currentUserLogin, localCurrencyCode} = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();
const {clearSelectedTransactions} = useSearchSelectionActions();
const defaultExpensePolicy = useDefaultExpensePolicy();
const {isBetaEnabled} = usePermissions();
Expand Down Expand Up @@ -83,6 +85,7 @@ function useBulkDuplicateAction({selectedTransactionsKeys, allTransactions, allR
recentWaypoints,
currentUser: {accountID, email: currentUserLogin ?? ''},
currentUserLocalCurrency: localCurrencyCode ?? CONST.CURRENCY.USD,
delegateAccountID,
policyTagList,
});

Expand Down
3 changes: 3 additions & 0 deletions src/hooks/useBulkDuplicateReportAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {hasSeenTourSelector} from '@selectors/Onboarding';

import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
import useDefaultExpensePolicy from './useDefaultExpensePolicy';
import useDelegateAccountID from './useDelegateAccountID';
import useLocalize from './useLocalize';
import useOnyx from './useOnyx';
import usePermissions from './usePermissions';
Expand All @@ -26,6 +27,7 @@ type UseBulkDuplicateReportActionParams = {

function useBulkDuplicateReportAction({selectedReports, allReports, searchData}: UseBulkDuplicateReportActionParams) {
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();
const {clearSelectedTransactions} = useSearchSelectionActions();
const defaultExpensePolicy = useDefaultExpensePolicy();
const {isBetaEnabled} = usePermissions();
Expand Down Expand Up @@ -67,6 +69,7 @@ function useBulkDuplicateReportAction({selectedReports, allReports, searchData}:
recentWaypoints,
currentUserLogin: currentUserPersonalDetails.login ?? '',
currentUserAccountID: currentUserPersonalDetails?.accountID,
delegateAccountID,
});

clearSelectedTransactions(undefined, true);
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/useExpenseActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import useConfirmModal from './useConfirmModal';
import {useCurrencyListActions} from './useCurrencyList';
import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
import useDefaultExpensePolicy from './useDefaultExpensePolicy';
import useDelegateAccountID from './useDelegateAccountID';
import useDeleteTransactions from './useDeleteTransactions';
import useDuplicateTransactionsAndViolations from './useDuplicateTransactionsAndViolations';
import useEnvironment from './useEnvironment';
Expand Down Expand Up @@ -102,6 +103,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
const {getCurrencyDecimals} = useCurrencyListActions();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const delegateAccountID = useDelegateAccountID();
const {login: currentUserLogin, accountID, email} = currentUserPersonalDetails;
const {currentSearchHash} = useSearchQueryContext();
const {removeTransaction} = useSearchSelectionActions();
Expand Down Expand Up @@ -270,6 +272,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic
targetPolicyTags,
currentUser: {accountID: currentUserPersonalDetails?.accountID, email: currentUserPersonalDetails?.email ?? ''},
currentUserLocalCurrency: currentUserPersonalDetails?.localCurrencyCode ?? CONST.CURRENCY.USD,
delegateAccountID,
policyTagList,
});
}
Expand Down Expand Up @@ -429,6 +432,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic
recentWaypoints: recentWaypoints ?? [],
currentUserAccountID: currentUserPersonalDetails?.accountID,
currentUserLogin: currentUserPersonalDetails?.email ?? '',
delegateAccountID,
});
},
},
Expand Down
2 changes: 2 additions & 0 deletions src/libs/IOUAmountSubmission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ function submitAmount({
isSelfTourViewed,
optimisticChatReportID,
optimisticTransactionID,
delegateAccountID,
reportActionsList: undefined,
});
} else {
Expand Down Expand Up @@ -372,6 +373,7 @@ function submitAmount({
personalDetails: allPersonalDetails,
optimisticChatReportID,
optimisticTransactionID,
delegateAccountID,
});
}
cleanupAfterSkipConfirmSubmit(overrides.shouldHandleNavigation, {
Expand Down
13 changes: 13 additions & 0 deletions src/libs/actions/IOU/Duplicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ type DuplicateExpenseTransactionParams = {
optimisticReportPreviewActionID?: string;
currentUser: CurrentUser;
currentUserLocalCurrency: string | undefined;
delegateAccountID: number | undefined;
policyTagList: OnyxTypes.PolicyTagLists;
};

Expand Down Expand Up @@ -779,6 +780,7 @@ function duplicateExpenseTransaction({
optimisticReportPreviewActionID: externalReportPreviewActionID,
currentUser,
currentUserLocalCurrency,
delegateAccountID,
policyTagList,
}: DuplicateExpenseTransactionParams) {
if (!transaction) {
Expand Down Expand Up @@ -827,6 +829,7 @@ function duplicateExpenseTransaction({
betas,
personalDetails,
shouldDeferAutoSubmit,
delegateAccountID,
};

// If no workspace is provided the expense should be unreported
Expand Down Expand Up @@ -866,6 +869,7 @@ function duplicateExpenseTransaction({
betas,
isSelfTourViewed,
currentUserLocalCurrency,
delegateAccountID,
reportActionsList: undefined,
};
return trackExpense(trackExpenseParams);
Expand Down Expand Up @@ -914,6 +918,7 @@ type DuplicateReportParams = {
currentUserLogin: string;
currentUserAccountID: number;
shouldPlaySound?: boolean;
delegateAccountID: number | undefined;
};

function duplicateReport({
Expand All @@ -937,6 +942,7 @@ function duplicateReport({
currentUserAccountID,
currentUserLogin,
shouldPlaySound = true,
delegateAccountID,
}: DuplicateReportParams) {
if (!targetPolicy || !parentChatReport) {
return;
Expand Down Expand Up @@ -1027,6 +1033,7 @@ function duplicateReport({
betas,
personalDetails,
shouldDeferAutoSubmit: !isLastExpense,
delegateAccountID,
};

const isMoneyRequestReport = isMoneyRequestReportReportUtils(params.report);
Expand Down Expand Up @@ -1085,6 +1092,7 @@ type BulkDuplicateExpensesParams = {
recentWaypoints: OnyxEntry<OnyxTypes.RecentWaypoint[]>;
currentUser: CurrentUser;
currentUserLocalCurrency: string | undefined;
delegateAccountID: number | undefined;
policyTagList: OnyxTypes.PolicyTagLists;
};

Expand All @@ -1107,6 +1115,7 @@ function bulkDuplicateExpenses({
recentWaypoints,
currentUser,
currentUserLocalCurrency,
delegateAccountID,
policyTagList,
}: BulkDuplicateExpensesParams) {
const transactionsToDuplicate = transactionIDs.map((id) => allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${id}`]).filter((t): t is OnyxTypes.Transaction => !!t);
Expand Down Expand Up @@ -1203,6 +1212,7 @@ function bulkDuplicateExpenses({
optimisticReportPreviewActionID: currentReportPreviewActionID,
currentUser,
currentUserLocalCurrency,
delegateAccountID,
policyTagList,
});

Expand Down Expand Up @@ -1239,6 +1249,7 @@ type BulkDuplicateReportsParams = {
recentWaypoints: OnyxEntry<OnyxTypes.RecentWaypoint[]>;
currentUserLogin: string;
currentUserAccountID: number;
delegateAccountID: number | undefined;
};

function bulkDuplicateReports({
Expand All @@ -1262,6 +1273,7 @@ function bulkDuplicateReports({
recentWaypoints,
currentUserLogin,
currentUserAccountID,
delegateAccountID,
}: BulkDuplicateReportsParams) {
const allTransactionsMap = getAllTransactions();
const transactionsByReportID = new Map<string, OnyxTypes.Transaction[]>();
Expand Down Expand Up @@ -1336,6 +1348,7 @@ function bulkDuplicateReports({
shouldPlaySound: false,
currentUserAccountID,
currentUserLogin,
delegateAccountID,
});
}

Expand Down
4 changes: 4 additions & 0 deletions src/libs/actions/IOU/MoneyRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type CreateTransactionParams = {
optimisticTransactionIDs: string[];
optimisticChatReportID: string | undefined;
currentUserLocalCurrency: string | undefined;
delegateAccountID: number | undefined;
};

function createTransaction({
Expand Down Expand Up @@ -123,6 +124,7 @@ function createTransaction({
optimisticTransactionIDs,
optimisticChatReportID,
currentUserLocalCurrency,
delegateAccountID,
}: CreateTransactionParams) {
const draftTransactionIDs = Object.keys(allTransactionDrafts ?? {});
const isMoneyRequestReport = isMoneyRequestReportReportUtils(report);
Expand Down Expand Up @@ -182,6 +184,7 @@ function createTransaction({
optimisticChatReportID,
optimisticTransactionID,
currentUserLocalCurrency,
delegateAccountID,
reportActionsList: undefined,
});
} else {
Expand Down Expand Up @@ -225,6 +228,7 @@ function createTransaction({
personalDetails,
optimisticChatReportID,
optimisticTransactionID,
delegateAccountID,
});
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/libs/actions/IOU/MoneyRequestBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ type RequestMoneyInformation = {
betas: OnyxEntry<OnyxTypes.Beta[]>;
personalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>;
shouldDeferAutoSubmit?: boolean;
// TODO: delegateAccountID will be made required in PR 10 when all callers pass the value (https://github.com/Expensify/App/issues/66425)
delegateAccountID?: number | undefined;
delegateAccountID: number | undefined;
};

type MoneyRequestInformationParams = {
Expand Down Expand Up @@ -221,8 +220,7 @@ type MoneyRequestInformationParams = {
quickAction: OnyxEntry<OnyxTypes.QuickAction>;
policyRecentlyUsedCurrencies: string[];
personalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>;
// TODO: delegateAccountID will be made required in PR 10 when all callers pass the value (https://github.com/Expensify/App/issues/66425)
delegateAccountID?: number | undefined;
delegateAccountID: number | undefined;
};

type MoneyRequestOptimisticParams = {
Expand Down Expand Up @@ -270,8 +268,7 @@ type BuildOnyxDataForMoneyRequestParams = {
transactionViolations?: OnyxCollection<OnyxTypes.TransactionViolations>;
hasViolations: boolean;
quickAction: OnyxEntry<OnyxTypes.QuickAction>;
// TODO: delegateAccountID will be made required in PR 10 when all callers pass the value (https://github.com/Expensify/App/issues/66425)
delegateAccountID?: number | undefined;
delegateAccountID: number | undefined;
personalDetails?: OnyxEntry<OnyxTypes.PersonalDetailsList>;
/** Whether this is a selfDM split transaction */
isSelfDMSplit?: boolean;
Expand Down
3 changes: 1 addition & 2 deletions src/libs/actions/IOU/Split.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ type CreateDistanceRequestInformation = {
optimisticReportPreviewActionID?: string;
shouldDeferAutoSubmit?: boolean;
previousOdometerDraft?: OnyxEntry<OnyxTypes.OdometerDraft>;
// TODO: delegateAccountID will be made required in PR 10 when all callers pass the value (https://github.com/Expensify/App/issues/66425)
delegateAccountID?: number | undefined;
delegateAccountID: number | undefined;
};

type CreateSplitsTransactionParams = Omit<BaseTransactionParams, 'customUnitRateID'> & {
Expand Down
4 changes: 4 additions & 0 deletions src/libs/actions/IOU/SplitTransactionUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,8 @@ function updateSplitTransactions({
policyRecentlyUsedCurrencies,
betas,
personalDetails,
// TODO: delegateAccountID will be threaded in PR 11 (https://github.com/Expensify/App/issues/66425)
Comment thread
Krishna2323 marked this conversation as resolved.
delegateAccountID: undefined,
} as MoneyRequestInformationParams;

if (isReverseSplitOperation) {
Expand Down Expand Up @@ -702,6 +704,8 @@ function updateSplitTransactions({
policyRecentlyUsedCurrencies,
betas,
personalDetails,
// TODO: delegateAccountID will be threaded in PR 11 (https://github.com/Expensify/App/issues/66425)
Comment thread
Krishna2323 marked this conversation as resolved.
delegateAccountID: undefined,
});

let updateMoneyRequestParamsOnyxData: OnyxData<UpdateMoneyRequestDataKeys> = {};
Expand Down
6 changes: 4 additions & 2 deletions src/libs/actions/IOU/TrackExpense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ type GetTrackExpenseInformationParams = {
defaultWorkspaceName?: string;
optimisticChatReportID?: string;
currentUserLocalCurrency: string | undefined;
// TODO: delegateAccountID will be made required in PR 10 when all callers pass the value (https://github.com/Expensify/App/issues/66425)
delegateAccountID?: number | undefined;
delegateAccountID: number | undefined;
// TODO: Remove optional (?) once all callers are updated in follow-up PRs of https://github.com/Expensify/App/issues/66414
isDraftChatReport?: boolean;
};
Expand Down Expand Up @@ -1946,6 +1945,7 @@ function convertBulkTrackedExpensesToIOU({
personalDetails,
betas,
policyTagList,
delegateAccountID,
}: {
transactions: OnyxTypes.Transaction[];
iouReport: OnyxEntry<OnyxTypes.Report>;
Expand All @@ -1959,6 +1959,7 @@ function convertBulkTrackedExpensesToIOU({
personalDetails: OnyxEntry<OnyxTypes.PersonalDetailsList>;
betas: OnyxEntry<OnyxTypes.Beta[]>;
policyTagList: OnyxEntry<OnyxTypes.PolicyTagLists>;
delegateAccountID: number | undefined;
}) {
const iouReportID = iouReport?.reportID;

Expand Down Expand Up @@ -2079,6 +2080,7 @@ function convertBulkTrackedExpensesToIOU({
policyParams: {
policyTagList,
},
delegateAccountID,
});

const isDistanceRequest = isDistanceRequestTransactionUtils(transaction);
Expand Down
3 changes: 1 addition & 2 deletions src/libs/actions/IOU/types/CreateTrackExpenseParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ type CreateTrackExpenseParams = {
defaultWorkspaceName?: string;
currentUserLocalCurrency: string | undefined;
previousOdometerDraft?: OnyxEntry<OnyxTypes.OdometerDraft>;
// TODO: delegateAccountID will be made required in PR 10 when all callers pass the value (https://github.com/Expensify/App/issues/66425)
delegateAccountID?: number | undefined;
delegateAccountID: number | undefined;
reportActionsList: OnyxCollection<OnyxTypes.ReportActions> | undefined;
// TODO: Remove optional (?) once all callers are updated in follow-up PRs of https://github.com/Expensify/App/issues/66414
isDraftChatReport?: boolean;
Expand Down
Loading
Loading