Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
df1d586
fix: remove currentUserEmail from Onyx.connect
linhvovan29546 Jan 1, 2026
f0f50d9
chore: remove currentUserEmail from onyx
linhvovan29546 Jan 1, 2026
b1faaff
chore: disable estlint until migration success
linhvovan29546 Jan 2, 2026
611b998
chore: prettier
linhvovan29546 Jan 2, 2026
dc8b49f
chore: make current user email required
linhvovan29546 Jan 2, 2026
5bcaeee
chore: pass email to isSplitAction
linhvovan29546 Jan 2, 2026
23fdb8a
test: add test for short mention in comment edits
linhvovan29546 Jan 2, 2026
bafad57
test: add test export to accounting action
linhvovan29546 Jan 2, 2026
f378b04
test: add test export to accounting action
linhvovan29546 Jan 2, 2026
975f680
chore: update prop
linhvovan29546 Jan 2, 2026
51303ad
chore: eslint fail
linhvovan29546 Jan 2, 2026
543bae4
chore: rename param
linhvovan29546 Jan 4, 2026
93242bc
chore: update current user email and account id to deprecated
linhvovan29546 Jan 4, 2026
2f13241
chore: update param name
linhvovan29546 Jan 4, 2026
81d3e67
Merge branch 'main' into fix/73648-remove-onyxkey-session-in-report-p…
linhvovan29546 Jan 7, 2026
af0bbb4
test: test fail after merge main
linhvovan29546 Jan 7, 2026
fb64b0b
Merge branch 'main' into fix/73648-remove-onyxkey-session-in-report-p…
linhvovan29546 Jan 8, 2026
68900ba
Update Mobile-Expensify submodule to match main
linhvovan29546 Jan 8, 2026
d56de90
chore: eslint fail
linhvovan29546 Jan 8, 2026
68f519c
chore: rename currentUserEmail to currentUserLogin
linhvovan29546 Jan 9, 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
6 changes: 3 additions & 3 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1513,9 +1513,9 @@ function MoneyReportHeader({
if (!hasFinishedPDFDownload || !canTriggerAutomaticPDFDownload.current) {
return;
}
downloadReportPDF(reportPDFFilename, moneyRequestReport?.reportName ?? '', translate);
downloadReportPDF(reportPDFFilename, moneyRequestReport?.reportName ?? '', translate, email ?? '');
Copy link
Contributor

Choose a reason for hiding this comment

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

This component already has currentUserLogin so reference that instead.

canTriggerAutomaticPDFDownload.current = false;
}, [hasFinishedPDFDownload, reportPDFFilename, moneyRequestReport?.reportName, translate]);
}, [hasFinishedPDFDownload, reportPDFFilename, moneyRequestReport?.reportName, translate, email]);

const shouldShowBackButton = shouldDisplayBackButton || shouldUseNarrowLayout;

Expand Down Expand Up @@ -1825,7 +1825,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 @@ -321,7 +321,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);
Copy link
Contributor

Choose a reason for hiding this comment

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

This component already has const currentUserEmailParam = currentUserPersonalDetails.login ?? '';. Would you please:

  1. Rename that const to currentUserLogin
  2. Update the existing references to the new constant name
  3. Use that same constant here for isSplitAction()


const canEditTaxFields = canEdit && !isDistanceRequest;
const canEditAmount =
Expand Down
9 changes: 4 additions & 5 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ function mapTransactionItemToSelectedEntry(
): [string, SelectedTransactionInfo] {
const {canHoldRequest, canUnholdRequest} = canHoldUnholdReportAction(item.report, item.reportAction, item.holdReportAction, item, item.policy);
const canRejectRequest = item.report ? canRejectReportAction(currentUserLogin, item.report, item.policy) : false;

return [
item.keyForList,
{
Expand All @@ -109,7 +108,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 @@ -161,7 +160,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 @@ -519,7 +518,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 @@ -572,7 +571,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),
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB: If email is aliased to be currentUserLogin, I think that would make it more consistent everywhere. Better yet, I think this component should use const {accountID, login} = useCurrentUserPersonalDetails(); (instead of email)

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();
Copy link
Contributor

Choose a reason for hiding this comment

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

Use login from this instead

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)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use login here too

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 @@ -1613,8 +1612,7 @@
return domainName;
};

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

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

/**
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, currentUserLogin: string, policy?: Policy) {
const isExpense = isExpenseReport(report);
const isExporter = policy ? isPreferredExporter(policy) : false;
const isExporter = policy ? isPreferredExporter(policy, currentUserLogin) : false;
const isReimbursed = isSettled(report);
const isClosed = isClosedReport(report);
const isApproved = isReportApproved({report});
Expand Down Expand Up @@ -222,7 +222,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 @@ -212,7 +212,7 @@ function isPrimaryPayAction(
return invoiceReceiverPolicy?.role === CONST.POLICY.ROLE.ADMIN && reimbursableSpend > 0;
}

function isExportAction(report: Report, policy?: Policy, reportActions?: ReportAction[]) {
function isExportAction(report: Report, currentUserLogin: string, policy?: Policy, reportActions?: ReportAction[]) {
if (!policy) {
return false;
}
Expand All @@ -226,7 +226,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, currentUserLogin);
if (!isReportExporter && !isAdmin) {
return false;
}
Expand Down Expand Up @@ -460,7 +460,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
35 changes: 20 additions & 15 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, ReportMetadata, 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 @@ -89,7 +89,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>,
currentUserLogin: string,
policy?: OnyxEntry<Policy>,
): boolean {
if (Number(reportTransactions?.length) !== 1 || !report) {
return false;
}
Expand Down Expand Up @@ -128,8 +134,7 @@ 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);
const userIsPolicyMember = isPolicyMember(policy, currentUserLogin);

if (!(userIsPolicyMember && isPolicyExpenseChat)) {
return false;
Expand Down Expand Up @@ -466,7 +471,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 @@ -758,7 +763,7 @@ function isDuplicateAction(report: Report, reportTransactions: Transaction[]): b
}

function getSecondaryReportActions({
currentUserEmail,
currentUserEmail: currentUserLogin,
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename the function parameter to currentUserLogin rather than keeping it currentUserEmail (this is the only place that getSecondaryReportActions() is called, so it's an easy change)

currentUserAccountID,
report,
chatReport,
Expand Down Expand Up @@ -794,7 +799,7 @@ function getSecondaryReportActions({
const didExportFail = !isExported && hasExportError;

if (
isPrimaryPayAction(report, currentUserAccountID, currentUserEmail, policy, reportNameValuePairs, isChatReportArchived, undefined, reportActions, true) &&
isPrimaryPayAction(report, currentUserAccountID, currentUserLogin, policy, reportNameValuePairs, isChatReportArchived, undefined, reportActions, true) &&
(hasOnlyHeldExpenses(report?.reportID) || didExportFail)
) {
options.push(CONST.REPORT.SECONDARY_ACTIONS.PAY);
Expand All @@ -805,7 +810,7 @@ function getSecondaryReportActions({
}

const primaryAction = getReportPrimaryAction({
currentUserEmail,
currentUserEmail: currentUserLogin,
currentUserAccountID,
report,
chatReport,
Expand All @@ -829,22 +834,22 @@ function getSecondaryReportActions({
isChatReportArchived,
primaryAction,
violations,
currentUserEmail,
currentUserEmail: currentUserLogin,
currentUserAccountID,
})
) {
options.push(CONST.REPORT.SECONDARY_ACTIONS.SUBMIT);
}

if (isApproveAction(currentUserEmail, report, reportTransactions, violations, policy)) {
if (isApproveAction(currentUserLogin, report, reportTransactions, violations, policy)) {
options.push(CONST.REPORT.SECONDARY_ACTIONS.APPROVE);
}

if (isUnapproveAction(currentUserEmail, report, policy)) {
if (isUnapproveAction(currentUserLogin, report, policy)) {
options.push(CONST.REPORT.SECONDARY_ACTIONS.UNAPPROVE);
}

if (isCancelPaymentAction(currentUserAccountID, currentUserEmail, report, reportTransactions, policy)) {
if (isCancelPaymentAction(currentUserAccountID, currentUserLogin, report, reportTransactions, policy)) {
options.push(CONST.REPORT.SECONDARY_ACTIONS.CANCEL_PAYMENT);
}

Expand All @@ -864,11 +869,11 @@ function getSecondaryReportActions({
options.push(CONST.REPORT.SECONDARY_ACTIONS.REMOVE_HOLD);
}

if (canRejectReportAction(currentUserEmail, report, policy)) {
if (canRejectReportAction(currentUserLogin, report, policy)) {
options.push(CONST.REPORT.SECONDARY_ACTIONS.REJECT);
}

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

Expand Down Expand Up @@ -955,7 +960,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
6 changes: 3 additions & 3 deletions src/libs/SearchUIUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ function getActions(
allViolations: OnyxCollection<OnyxTypes.TransactionViolation[]>,
key: string,
currentSearch: SearchKey,
currentUserEmail: string,
currentUserLogin: string,
reportActions: OnyxTypes.ReportAction[] = [],
): SearchTransactionAction[] {
const isTransaction = isTransactionEntry(key);
Expand All @@ -1402,7 +1402,7 @@ function getActions(
}

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

if (isSettled(report) && !isExportAvailable) {
return [CONST.SEARCH.ACTION_TYPES.PAID];
Expand Down Expand Up @@ -1477,7 +1477,7 @@ function getActions(
}

// We check for isAllowedToApproveExpenseReport because if the policy has preventSelfApprovals enabled, we disable the Submit action and in that case we want to show the View action instead
if (canSubmitReport(report, policy, allReportTransactions, allViolations, isIOUReportArchived || isChatReportArchived, currentUserEmail) && isAllowedToApproveExpenseReport) {
if (canSubmitReport(report, policy, allReportTransactions, allViolations, isIOUReportArchived || isChatReportArchived, currentUserLogin) && isAllowedToApproveExpenseReport) {
allActions.push(CONST.SEARCH.ACTION_TYPES.SUBMIT);
}

Expand Down
Loading
Loading