Skip to content
Open
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
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 @@ -49,6 +50,7 @@ function AddExistingExpenseFooter({selectedIds, report, reportToConfirm, reportN
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
const session = useSession();
const personalDetails = usePersonalDetails();
const delegateAccountID = useDelegateAccountID();
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);
const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
const [policyRecentlyUsedCurrencies] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES);
Expand Down Expand Up @@ -82,6 +84,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 @@ -107,6 +108,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 @@ -256,6 +258,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
targetPolicyTags,
currentUser: {accountID, email: currentUserLogin ?? ''},
currentUserLocalCurrency: localCurrencyCode ?? CONST.CURRENCY.USD,
delegateAccountID,
});
}
};
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 useOnyx from './useOnyx';
import usePermissions from './usePermissions';

Expand All @@ -32,6 +33,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 @@ -81,6 +83,7 @@ function useBulkDuplicateAction({selectedTransactionsKeys, allTransactions, allR
recentWaypoints,
currentUser: {accountID, email: currentUserLogin ?? ''},
currentUserLocalCurrency: localCurrencyCode ?? CONST.CURRENCY.USD,
delegateAccountID,
});

if (onAfterDuplicate) {
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 @@ -58,6 +58,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 @@ -99,6 +100,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 @@ -265,6 +267,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic
targetPolicyTags,
currentUser: {accountID: currentUserPersonalDetails?.accountID, email: currentUserPersonalDetails?.email ?? ''},
currentUserLocalCurrency: currentUserPersonalDetails?.localCurrencyCode ?? CONST.CURRENCY.USD,
delegateAccountID,
});
}
};
Expand Down Expand Up @@ -423,6 +426,7 @@ function useExpenseActions({reportID, isReportInSearch = false, backTo, onDuplic
recentWaypoints: recentWaypoints ?? [],
currentUserAccountID: currentUserPersonalDetails?.accountID,
currentUserLogin: currentUserPersonalDetails?.email ?? '',
delegateAccountID,
});
},
},
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 @@ -759,6 +759,7 @@ type DuplicateExpenseTransactionParams = {
optimisticReportPreviewActionID?: string;
currentUser: CurrentUser;
currentUserLocalCurrency: string | undefined;
delegateAccountID: number | undefined;
};

function duplicateExpenseTransaction({
Expand All @@ -785,6 +786,7 @@ function duplicateExpenseTransaction({
optimisticReportPreviewActionID: externalReportPreviewActionID,
currentUser,
currentUserLocalCurrency,
delegateAccountID,
}: DuplicateExpenseTransactionParams) {
if (!transaction) {
return;
Expand Down Expand Up @@ -832,6 +834,7 @@ function duplicateExpenseTransaction({
betas,
personalDetails,
shouldDeferAutoSubmit,
delegateAccountID,
};

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

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

const result = createExpenseByType({
Expand Down Expand Up @@ -1075,6 +1082,7 @@ type BulkDuplicateExpensesParams = {
recentWaypoints: OnyxEntry<OnyxTypes.RecentWaypoint[]>;
currentUser: CurrentUser;
currentUserLocalCurrency: string | undefined;
delegateAccountID: number | undefined;
};

function bulkDuplicateExpenses({
Expand All @@ -1096,6 +1104,7 @@ function bulkDuplicateExpenses({
recentWaypoints,
currentUser,
currentUserLocalCurrency,
delegateAccountID,
}: BulkDuplicateExpensesParams) {
const transactionsToDuplicate = transactionIDs.map((id) => allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${id}`]).filter((t): t is OnyxTypes.Transaction => !!t);

Expand Down Expand Up @@ -1191,6 +1200,7 @@ function bulkDuplicateExpenses({
optimisticReportPreviewActionID: currentReportPreviewActionID,
currentUser,
currentUserLocalCurrency,
delegateAccountID,
});

if (result?.iouReport) {
Expand Down Expand Up @@ -1226,6 +1236,7 @@ type BulkDuplicateReportsParams = {
recentWaypoints: OnyxEntry<OnyxTypes.RecentWaypoint[]>;
currentUserLogin: string;
currentUserAccountID: number;
delegateAccountID: number | undefined;
};

function bulkDuplicateReports({
Expand All @@ -1249,6 +1260,7 @@ function bulkDuplicateReports({
recentWaypoints,
currentUserLogin,
currentUserAccountID,
delegateAccountID,
}: BulkDuplicateReportsParams) {
const allTransactionsMap = getAllTransactions();
const transactionsByReportID = new Map<string, OnyxTypes.Transaction[]>();
Expand Down Expand Up @@ -1323,6 +1335,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 @@ -93,6 +93,7 @@ type CreateTransactionParams = {
optimisticTransactionIDs: string[];
optimisticChatReportID: string | undefined;
currentUserLocalCurrency: string | undefined;
delegateAccountID: number | undefined;
};

function createTransaction({
Expand Down Expand Up @@ -121,6 +122,7 @@ function createTransaction({
optimisticTransactionIDs,
optimisticChatReportID,
currentUserLocalCurrency,
delegateAccountID,
}: CreateTransactionParams) {
const draftTransactionIDs = Object.keys(allTransactionDrafts ?? {});

Expand Down Expand Up @@ -168,6 +170,7 @@ function createTransaction({
optimisticChatReportID,
optimisticTransactionID,
currentUserLocalCurrency,
delegateAccountID,
});
} else {
const existingTransactionID = getExistingTransactionID(transaction?.linkedTrackedExpenseReportAction);
Expand Down Expand Up @@ -210,6 +213,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 @@ -145,8 +145,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;
};

type DeleteTrackExpenseParams = {
Expand Down Expand Up @@ -1951,6 +1950,7 @@ function convertBulkTrackedExpensesToIOU({
personalDetails,
betas,
policyTagList,
delegateAccountID,
}: {
transactions: OnyxTypes.Transaction[];
iouReport: OnyxEntry<OnyxTypes.Report>;
Expand All @@ -1964,6 +1964,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 @@ -2084,6 +2085,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;
// TODO: Remove optional (?) once all callers are updated in follow-up PRs of https://github.com/Expensify/App/issues/66578
reportActionsList?: OnyxCollection<OnyxTypes.ReportActions>;
// Personal details list is optional here because we only use/pass it for SHARE case
Expand Down
4 changes: 4 additions & 0 deletions src/pages/Share/SubmitDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import MoneyRequestConfirmationList from '@components/MoneyRequestConfirmationLi
import ScreenWrapper from '@components/ScreenWrapper';

import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDelegateAccountID from '@hooks/useDelegateAccountID';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
Expand Down Expand Up @@ -74,6 +75,7 @@ function SubmitDetailsPage({
}: ShareDetailsPageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const delegateAccountID = useDelegateAccountID();
const [unknownUserDetails] = useOnyx(ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS);
const [personalDetails] = useOnyx(`${ONYXKEYS.PERSONAL_DETAILS_LIST}`);
const report: OnyxEntry<ReportType> = useReportOrReportDraft(reportOrAccountID);
Expand Down Expand Up @@ -289,6 +291,7 @@ function SubmitDetailsPage({
isSelfTourViewed,
optimisticTransactionID,
currentUserLocalCurrency: currentUserPersonalDetails.localCurrencyCode ?? CONST.CURRENCY.USD,
delegateAccountID,
});
} else {
const existingTransactionDraft = existingTransactionID ? transactionDrafts?.[existingTransactionID] : undefined;
Expand Down Expand Up @@ -333,6 +336,7 @@ function SubmitDetailsPage({
betas,
personalDetails,
optimisticTransactionID,
delegateAccountID,
});
}
cleanupAndNavigateAfterExpenseCreate({
Expand Down
Loading
Loading