Skip to content
Open
6 changes: 3 additions & 3 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1478,9 +1478,9 @@ function MoneyReportHeader({
if (!hasFinishedPDFDownload || !canTriggerAutomaticPDFDownload.current) {
return;
}
downloadReportPDF(reportPDFFilename, moneyRequestReport?.reportName ?? '', translate);
downloadReportPDF(reportPDFFilename, moneyRequestReport?.reportName ?? '', translate, email ?? '');
canTriggerAutomaticPDFDownload.current = false;
}, [hasFinishedPDFDownload, reportPDFFilename, moneyRequestReport?.reportName, translate]);
}, [hasFinishedPDFDownload, reportPDFFilename, moneyRequestReport?.reportName, translate, email]);

const shouldShowBackButton = shouldDisplayBackButton || shouldUseNarrowLayout;

Expand Down Expand Up @@ -1789,7 +1789,7 @@ function MoneyReportHeader({
if (!hasFinishedPDFDownload) {
setIsPDFModalVisible(false);
} else {
downloadReportPDF(reportPDFFilename, moneyRequestReport?.reportName ?? '', translate);
downloadReportPDF(reportPDFFilename, moneyRequestReport?.reportName ?? '', translate, email ?? '');
}
}}
text={hasFinishedPDFDownload ? translate('common.download') : translate('common.cancel')}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ function MoneyRequestView({
const companyCardPageURL = `${environmentURL}/${ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(transactionThreadReport?.policyID)}`;
const [originalTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(transaction?.comment?.originalTransactionID)}`, {canBeMissing: true});
const {isExpenseSplit} = getOriginalTransactionWithSplitInfo(transaction, originalTransaction);
const isSplitAvailable = moneyRequestReport && transaction && isSplitAction(moneyRequestReport, [transaction], originalTransaction, policy);
const isSplitAvailable = moneyRequestReport && transaction && isSplitAction(moneyRequestReport, [transaction], originalTransaction, currentUserPersonalDetails.email ?? '', policy);

const canEditTaxFields = canEdit && !isDistanceRequest;
const canEditAmount =
Expand Down
8 changes: 4 additions & 4 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function mapTransactionItemToSelectedEntry(
canHold: canHoldRequest,
isHeld: isOnHold(item),
canUnhold: canUnholdRequest,
canSplit: isSplitAction(item.report, [itemTransaction], originalItemTransaction, item.policy),
canSplit: isSplitAction(item.report, [itemTransaction], originalItemTransaction, currentUserLogin, item.policy),
hasBeenSplit: getOriginalTransactionWithSplitInfo(itemTransaction, originalItemTransaction).isExpenseSplit,
canChangeReport: canEditFieldOfMoneyRequest(
item.reportAction,
Expand Down Expand Up @@ -162,7 +162,7 @@ function prepareTransactionsList(
canHold: canHoldRequest,
isHeld: isOnHold(item),
canUnhold: canUnholdRequest,
canSplit: isSplitAction(item.report, [itemTransaction], originalItemTransaction, item.policy),
canSplit: isSplitAction(item.report, [itemTransaction], originalItemTransaction, currentUserLogin, item.policy),
hasBeenSplit: getOriginalTransactionWithSplitInfo(itemTransaction, originalItemTransaction).isExpenseSplit,
canChangeReport: canEditFieldOfMoneyRequest(
item.reportAction,
Expand Down Expand Up @@ -509,7 +509,7 @@ function Search({
canHold: canHoldRequest,
isHeld: isOnHold(transactionItem),
canUnhold: canUnholdRequest,
canSplit: isSplitAction(transactionItem.report, [itemTransaction], originalItemTransaction, transactionItem.policy),
canSplit: isSplitAction(transactionItem.report, [itemTransaction], originalItemTransaction, email ?? '', transactionItem.policy),
hasBeenSplit: getOriginalTransactionWithSplitInfo(itemTransaction, originalItemTransaction).isExpenseSplit,
canChangeReport: canEditFieldOfMoneyRequest(
transactionItem.reportAction,
Expand Down Expand Up @@ -562,7 +562,7 @@ function Search({
canHold: canHoldRequest,
isHeld: isOnHold(transactionItem),
canUnhold: canUnholdRequest,
canSplit: isSplitAction(transactionItem.report, [itemTransaction], originalItemTransaction, transactionItem.policy),
canSplit: isSplitAction(transactionItem.report, [itemTransaction], originalItemTransaction, email ?? '', transactionItem.policy),
hasBeenSplit: getOriginalTransactionWithSplitInfo(itemTransaction, originalItemTransaction).isExpenseSplit,
canChangeReport: canEditFieldOfMoneyRequest(
transactionItem.reportAction,
Expand Down
5 changes: 4 additions & 1 deletion src/hooks/useSelectedTransactionsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Policy, Report, ReportAction, Session, Transaction} from '@src/types/onyx';
import useAllTransactions from './useAllTransactions';
import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
import useDeleteTransactions from './useDeleteTransactions';
import useDuplicateTransactionsAndViolations from './useDuplicateTransactionsAndViolations';
import {useMemoizedLazyExpensifyIcons} from './useLazyAsset';
Expand Down Expand Up @@ -76,6 +77,7 @@ function useSelectedTransactionsActions({
const {duplicateTransactions, duplicateTransactionViolations} = useDuplicateTransactionsAndViolations(selectedTransactionIDs);
const isReportArchived = useReportIsArchived(report?.reportID);
const {deleteTransactions} = useDeleteTransactions({report, reportActions, policy});
const {email} = useCurrentUserPersonalDetails();
const selectedTransactionsList = useMemo(
() =>
selectedTransactionIDs.reduce((acc, transactionID) => {
Expand Down Expand Up @@ -329,7 +331,7 @@ function useSelectedTransactionsActions({
const originalTransaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${firstTransaction?.comment?.originalTransactionID}`];

const {isExpenseSplit} = getOriginalTransactionWithSplitInfo(firstTransaction, originalTransaction);
const canSplitTransaction = selectedTransactionsList.length === 1 && report && !isExpenseSplit && isSplitAction(report, [firstTransaction], originalTransaction, policy);
const canSplitTransaction = selectedTransactionsList.length === 1 && report && !isExpenseSplit && isSplitAction(report, [firstTransaction], originalTransaction, email ?? '', policy);

if (canSplitTransaction) {
options.push({
Expand Down Expand Up @@ -398,6 +400,7 @@ function useSelectedTransactionsActions({
expensifyIcons.Trashcan,
localeCompare,
isOnSearch,
email,
]);

return {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useTodos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function useTodos() {
if (isPrimaryPayAction(report, accountID, email, policy, reportNameValuePair)) {
reportsToPay.push(report);
}
if (isExportAction(report, policy, reportActions)) {
if (isExportAction(report, email, policy, reportActions)) {
reportsToExport.push(report);
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import {getBankAccountFromID} from './actions/BankAccounts';
import {hasSynchronizationErrorMessage, isConnectionUnverified} from './actions/connections';
import {shouldShowQBOReimbursableExportDestinationAccountError} from './actions/connections/QuickbooksOnline';
import {getCurrentUserEmail} from './actions/Report';
import {getCategoryApproverRule} from './CategoryUtils';
import Navigation from './Navigation/Navigation';
import {isOffline as isOfflineNetworkStore} from './Network/NetworkStore';
Expand All @@ -60,7 +59,7 @@

let allPolicies: OnyxCollection<Policy>;

Onyx.connect({

Check warning on line 62 in src/libs/PolicyUtils.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) => (allPolicies = value),
Expand Down Expand Up @@ -1631,8 +1630,7 @@
return domainName;
};

function isPreferredExporter(policy: Policy) {
const user = getCurrentUserEmail();
function isPreferredExporter(policy: Policy, currentUserEmail: string) {
const exporters = [
policy.connections?.intacct?.config?.export?.exporter,
policy.connections?.netsuite?.options?.config?.exporter,
Expand All @@ -1641,7 +1639,7 @@
policy.connections?.xero?.config?.export?.exporter,
];

return exporters.some((exporter) => exporter && exporter === user);
return exporters.some((exporter) => exporter && exporter === currentUserEmail);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/libs/ReportPreviewActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ function canPay(report: Report, isReportArchived: boolean, currentUserAccountID:
return invoiceReceiverPolicy?.role === CONST.POLICY.ROLE.ADMIN && reimbursableSpend > 0;
}

function canExport(report: Report, policy?: Policy) {
function canExport(report: Report, currentUserEmail: string, policy?: Policy) {
const isExpense = isExpenseReport(report);
const isExporter = policy ? isPreferredExporter(policy) : false;
const isExporter = policy ? isPreferredExporter(policy, currentUserEmail) : false;
const isReimbursed = isSettled(report);
const isClosed = isClosedReport(report);
const isApproved = isReportApproved({report});
Expand Down Expand Up @@ -216,7 +216,7 @@ function getReportPreviewAction({
if (canPay(report, isReportArchived, currentUserAccountID, currentUserEmail, policy, invoiceReceiverPolicy)) {
return CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY;
}
if (canExport(report, policy)) {
if (canExport(report, currentUserEmail, policy)) {
return CONST.REPORT.REPORT_PREVIEW_ACTIONS.EXPORT_TO_ACCOUNTING;
}

Expand Down
6 changes: 3 additions & 3 deletions src/libs/ReportPrimaryActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function isPrimaryPayAction(
return invoiceReceiverPolicy?.role === CONST.POLICY.ROLE.ADMIN && reimbursableSpend > 0;
}

function isExportAction(report: Report, policy?: Policy, reportActions?: ReportAction[]) {
function isExportAction(report: Report, currentUserEmail: string, policy?: Policy, reportActions?: ReportAction[]) {
if (!policy) {
return false;
}
Expand All @@ -219,7 +219,7 @@ function isExportAction(report: Report, policy?: Policy, reportActions?: ReportA

const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;

const isReportExporter = isPreferredExporter(policy);
const isReportExporter = isPreferredExporter(policy, currentUserEmail);
if (!isReportExporter && !isAdmin) {
return false;
}
Expand Down Expand Up @@ -451,7 +451,7 @@ function getReportPrimaryAction(params: GetReportPrimaryActionParams): ValueOf<t
return CONST.REPORT.PRIMARY_ACTIONS.PAY;
}

if (isExportAction(report, policy, reportActions)) {
if (isExportAction(report, currentUserEmail, policy, reportActions)) {
return CONST.REPORT.PRIMARY_ACTIONS.EXPORT_TO_ACCOUNTING;
}

Expand Down
17 changes: 11 additions & 6 deletions src/libs/ReportSecondaryActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {ExportTemplate, Policy, Report, ReportAction, ReportNameValuePairs, Transaction, TransactionViolation} from '@src/types/onyx';
import {isApprover as isApproverUtils} from './actions/Policy/Member';
import {getCurrentUserAccountID, getCurrentUserEmail} from './actions/Report';
import {getCurrentUserAccountID} from './actions/Report';
import {areTransactionsEligibleForMerge} from './MergeTransactionUtils';
import {getLoginByAccountID} from './PersonalDetailsUtils';
import {
Expand Down Expand Up @@ -80,7 +80,13 @@ function isAddExpenseAction(report: Report, reportTransactions: Transaction[], i
return canAddTransaction(report, isReportArchived);
}

function isSplitAction(report: OnyxEntry<Report>, reportTransactions: Array<OnyxEntry<Transaction>>, originalTransaction: OnyxEntry<Transaction>, policy?: OnyxEntry<Policy>): boolean {
function isSplitAction(
report: OnyxEntry<Report>,
reportTransactions: Array<OnyxEntry<Transaction>>,
originalTransaction: OnyxEntry<Transaction>,
currentUserEmail: string,
policy?: OnyxEntry<Policy>,
): boolean {
if (Number(reportTransactions?.length) !== 1 || !report) {
return false;
}
Expand Down Expand Up @@ -119,7 +125,6 @@ function isSplitAction(report: OnyxEntry<Report>, reportTransactions: Array<Onyx
const isManager = (report.managerID ?? CONST.DEFAULT_NUMBER_ID) === getCurrentUserAccountID();
const isOpenReport = isOpenReportUtils(report);
const isPolicyExpenseChat = !!policy?.isPolicyExpenseChatEnabled;
const currentUserEmail = getCurrentUserEmail();
const userIsPolicyMember = isPolicyMember(policy, currentUserEmail);

if (!(userIsPolicyMember && isPolicyExpenseChat)) {
Expand Down Expand Up @@ -440,7 +445,7 @@ function isMarkAsExportedAction(currentAccountID: number, currentUserEmail: stri

const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;

const isExporter = isPreferredExporter(policy);
const isExporter = isPreferredExporter(policy, currentUserEmail);

return (isAdmin && syncEnabled) || (isExporter && !syncEnabled);
}
Expand Down Expand Up @@ -825,7 +830,7 @@ function getSecondaryReportActions({
options.push(CONST.REPORT.SECONDARY_ACTIONS.REJECT);
}

if (isSplitAction(report, reportTransactions, originalTransaction, policy)) {
if (isSplitAction(report, reportTransactions, originalTransaction, currentUserEmail, policy)) {
options.push(CONST.REPORT.SECONDARY_ACTIONS.SPLIT);
}

Expand Down Expand Up @@ -912,7 +917,7 @@ function getSecondaryTransactionThreadActions(
options.push(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.REJECT);
}

if (isSplitAction(parentReport, [reportTransaction], originalTransaction, policy)) {
if (isSplitAction(parentReport, [reportTransaction], originalTransaction, currentUserEmail, policy)) {
options.push(CONST.REPORT.TRANSACTION_SECONDARY_ACTIONS.SPLIT);
}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ function getActions(
}

const policy = getPolicyFromKey(data, report);
const isExportAvailable = isExportAction(report, policy, reportActions) && !isTransaction;
const isExportAvailable = isExportAction(report, currentUserEmail, policy, reportActions) && !isTransaction;

if (isSettled(report) && !isExportAvailable) {
return [CONST.SEARCH.ACTION_TYPES.PAID];
Expand Down
21 changes: 11 additions & 10 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,10 @@
const addNewMessageWithText = new Set<string>([WRITE_COMMANDS.ADD_COMMENT, WRITE_COMMANDS.ADD_TEXT_AND_ATTACHMENT]);
let conciergeReportID: string | undefined;
let currentUserAccountID = -1;
/** @deprecated This value is deprecated and will be removed soon after migration. Use the email from useCurrentUserPersonalDetails hook instead. */
let currentUserEmail: string | undefined;
Copy link
Contributor Author

@linhvovan29546 linhvovan29546 Jan 2, 2026

Choose a reason for hiding this comment

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

currentUserEmail still exists in some complex areas(OpenReport...), so I’ve marked it as deprecated and will remove it in other PR. #73648 (comment)


Onyx.connect({

Check warning on line 280 in src/libs/actions/Report.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 @@ -284,12 +285,13 @@
conciergeReportID = undefined;
return;
}
// eslint-disable-next-line @typescript-eslint/no-deprecated
currentUserEmail = value.email;
currentUserAccountID = value.accountID;
},
});

Onyx.connect({

Check warning on line 294 in src/libs/actions/Report.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) => (conciergeReportID = value),
});
Expand All @@ -297,7 +299,7 @@
// map of reportID to all reportActions for that report
const allReportActions: OnyxCollection<ReportActions> = {};

Onyx.connect({

Check warning on line 302 in src/libs/actions/Report.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,
callback: (actions, key) => {
if (!key || !actions) {
Expand All @@ -309,14 +311,14 @@
});

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

Check warning on line 314 in src/libs/actions/Report.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) => (allTransactionViolations = value),
});

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

Check warning on line 321 in src/libs/actions/Report.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 @@ -325,7 +327,7 @@
});

let allPersonalDetails: OnyxEntry<PersonalDetailsList> = {};
Onyx.connect({

Check warning on line 330 in src/libs/actions/Report.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 All @@ -340,7 +342,7 @@
});

let onboarding: OnyxEntry<Onboarding>;
Onyx.connect({

Check warning on line 345 in src/libs/actions/Report.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.NVP_ONBOARDING,
callback: (val) => {
if (Array.isArray(val)) {
Expand All @@ -351,13 +353,13 @@
});

let introSelected: OnyxEntry<IntroSelected> = {};
Onyx.connect({

Check warning on line 356 in src/libs/actions/Report.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.NVP_INTRO_SELECTED,
callback: (val) => (introSelected = val),
});

let allReportDraftComments: Record<string, string | undefined> = {};
Onyx.connect({

Check warning on line 362 in src/libs/actions/Report.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_COMMENT,
waitForCollectionCallback: true,
callback: (value) => (allReportDraftComments = value),
Expand Down Expand Up @@ -1076,6 +1078,7 @@
const parentReport =
transactionParentReportID === optimisticSelfDMReport?.reportID ? optimisticSelfDMReport : allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${transactionParentReportID}`];
const submitterAccountID = parentReport?.ownerAccountID ?? currentUserAccountID;
// eslint-disable-next-line @typescript-eslint/no-deprecated
const submitterEmail = PersonalDetailsUtils.getLoginsByAccountIDs([submitterAccountID]).at(0) ?? currentUserEmail ?? '';
const submitterPersonalDetails = PersonalDetailsUtils.getPersonalDetailByEmail(submitterEmail);

Expand Down Expand Up @@ -1203,6 +1206,7 @@
const isGroupChat = isGroupChatReportUtils(newReportObject);
if (isGroupChat) {
parameters.chatType = CONST.REPORT.CHAT_TYPE.GROUP;
// eslint-disable-next-line @typescript-eslint/no-deprecated
parameters.groupChatAdminLogins = currentUserEmail;
parameters.optimisticAccountIDList = Object.keys(newReportObject?.participants ?? {}).join(',');
parameters.reportName = newReportObject?.reportName ?? '';
Expand Down Expand Up @@ -1445,6 +1449,7 @@
openReport(
optimisticTransactionThreadReportID,
undefined,
// eslint-disable-next-line @typescript-eslint/no-deprecated
currentUserEmail ? [currentUserEmail] : [],
optimisticTransactionThread,
iouReportAction?.reportActionID,
Expand Down Expand Up @@ -2143,12 +2148,12 @@
* @param originalCommentMarkdown original markdown of the comment before editing.
* @param videoAttributeCache cache of video attributes ([videoSource]: videoAttributes)
*/
function handleUserDeletedLinksInHtml(newCommentText: string, originalCommentMarkdown: string, videoAttributeCache?: Record<string, string>): string {
function handleUserDeletedLinksInHtml(newCommentText: string, originalCommentMarkdown: string, userEmail: string, videoAttributeCache?: Record<string, string>): string {
if (newCommentText.length > CONST.MAX_MARKUP_LENGTH) {
return newCommentText;
}

const userEmailDomain = isEmailPublicDomain(currentUserEmail ?? '') ? '' : Str.extractEmailDomain(currentUserEmail ?? '');
const userEmailDomain = isEmailPublicDomain(userEmail) ? '' : Str.extractEmailDomain(userEmail);
const allPersonalDetailLogins = Object.values(allPersonalDetails ?? {}).map((personalDetail) => personalDetail?.login ?? '');

const htmlForNewComment = getParsedMessageWithShortMentions({
Expand All @@ -2172,6 +2177,7 @@
textForNewComment: string,
isOriginalReportArchived: boolean | undefined,
isOriginalParentReportArchived: boolean | undefined,
userEmail: string,
videoAttributeCache?: Record<string, string>,
) {
const originalReportID = originalReport?.reportID;
Expand All @@ -2191,7 +2197,7 @@
if (originalCommentMarkdown === textForNewComment) {
return;
}
const htmlForNewComment = handleUserDeletedLinksInHtml(textForNewComment, originalCommentMarkdown, videoAttributeCache);
const htmlForNewComment = handleUserDeletedLinksInHtml(textForNewComment, originalCommentMarkdown, userEmail, videoAttributeCache);

const reportComment = Parser.htmlToText(htmlForNewComment);

Expand Down Expand Up @@ -3631,10 +3637,6 @@
return currentUserAccountID;
}

function getCurrentUserEmail(): string | undefined {
return currentUserEmail;
}

function navigateToMostRecentReport(currentReport: OnyxEntry<Report>) {
const lastAccessedReportID = findLastAccessedReport(false, false, undefined, currentReport?.reportID)?.reportID;

Expand Down Expand Up @@ -4923,12 +4925,12 @@
API.write(WRITE_COMMANDS.EXPORT_REPORT_TO_PDF, params, {optimisticData, failureData});
}

function downloadReportPDF(fileName: string, reportName: string, translate: LocalizedTranslate) {
function downloadReportPDF(fileName: string, reportName: string, translate: LocalizedTranslate, userEmail: string) {
const baseURL = addTrailingForwardSlash(getOldDotURLFromEnvironment(environment));
const downloadFileName = `${reportName}.pdf`;
setDownload(fileName, true);
const pdfURL = `${baseURL}secure?secureType=pdfreport&filename=${encodeURIComponent(fileName)}&downloadName=${encodeURIComponent(downloadFileName)}&email=${encodeURIComponent(
currentUserEmail ?? '',
userEmail,
)}`;
fileDownload(translate, addEncryptedAuthTokenToURL(pdfURL, true), downloadFileName, '', Browser.isMobileSafari()).then(() => setDownload(fileName, false));
}
Expand Down Expand Up @@ -6321,7 +6323,6 @@
exportToIntegration,
flagComment,
getCurrentUserAccountID,
getCurrentUserEmail,
getMostRecentReportID,
getNewerActions,
getOlderActions,
Expand Down
Loading
Loading