From 228217051be31aa1138153129893e4826e75bb18 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sun, 7 Dec 2025 12:49:32 +0530 Subject: [PATCH 01/16] Refactor session subscription on SessionUtils --- src/libs/SessionUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SessionUtils.ts b/src/libs/SessionUtils.ts index 43445f8a21438..237ae33adb80f 100644 --- a/src/libs/SessionUtils.ts +++ b/src/libs/SessionUtils.ts @@ -35,7 +35,7 @@ let currentSession: OnyxEntry; // To tell if the user logged in during this session we will check the value of session.authToken once when the app's JS inits. When the user logs out // we can reset this flag so that it can be updated again. -Onyx.connect({ +Onyx.connectWithoutView({ key: ONYXKEYS.SESSION, callback: (session) => { currentSession = session; From c4034f699b4fd7d8bc040bd2b30924c6d3d97f34 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sun, 7 Dec 2025 13:02:15 +0530 Subject: [PATCH 02/16] Remove session from ioU --- src/libs/actions/IOU.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 3d482d79e6bf2..76ce6d0731361 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -11754,9 +11754,7 @@ function completePaymentOnboarding( return; } - const session = getSession(); - - const personalDetailsListValues = Object.values(getPersonalDetailsForAccountIDs(session?.accountID ? [session.accountID] : [], personalDetailsList)); + const personalDetailsListValues = Object.values(getPersonalDetailsForAccountIDs(userAccountID ? [userAccountID] : [], personalDetailsList)); const personalDetails = personalDetailsListValues.at(0); let onboardingPurpose = introSelected?.choice; From 159543c139f2c5af99e281279dc698a7de36ccbe Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sun, 7 Dec 2025 13:02:29 +0530 Subject: [PATCH 03/16] Refactor firebase utils to remove session values --- src/libs/Firebase/utils.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libs/Firebase/utils.ts b/src/libs/Firebase/utils.ts index 6b9038d5e30c2..a122ed0082db6 100644 --- a/src/libs/Firebase/utils.ts +++ b/src/libs/Firebase/utils.ts @@ -1,8 +1,8 @@ // We have opted for `Onyx.connectWithoutView` here as this logic is strictly non-UI in nature. -import Onyx from 'react-native-onyx'; -import * as SessionUtils from '@libs/SessionUtils'; +import Onyx, { OnyxEntry } from 'react-native-onyx'; import ONYXKEYS from '@src/ONYXKEYS'; import type {PerfAttributes} from './types'; +import { Session } from '@src/types/onyx'; let reportsCount = 0; Onyx.connectWithoutView({ @@ -57,9 +57,15 @@ Onyx.connectWithoutView({ }, }); -function getAttributes(attributes?: T[]): Pick { - const session = SessionUtils.getSession(); +let session: OnyxEntry; +Onyx.connectWithoutView({ + key: ONYXKEYS.SESSION, + callback: (value) => { + session = value; + }, +}); +function getAttributes(attributes?: T[]): Pick { const allAttributes: PerfAttributes = { accountId: session?.accountID?.toString() ?? 'N/A', reportsLength: reportsCount.toString(), From 63bb10d78e85cb078955bbd9e2a55235ca83482f Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sun, 7 Dec 2025 13:16:46 +0530 Subject: [PATCH 04/16] Refactor isPayer function to not use session --- .../MoneyRequestReportPreviewContent.tsx | 1 + src/libs/NextStepUtils.ts | 43 +++---------------- src/libs/ReportPreviewActionUtils.ts | 7 +-- src/libs/ReportPrimaryActionUtils.ts | 17 ++++++-- src/libs/ReportSecondaryActionUtils.ts | 2 +- src/libs/ReportUtils.ts | 6 +-- 6 files changed, 27 insertions(+), 49 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 3a2419ca318e6..31e5cfc1cc131 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -492,6 +492,7 @@ function MoneyRequestReportPreviewContent({ return getReportPreviewAction( isIouReportArchived || isChatReportArchived, currentUserDetails.accountID, + currentUserDetails.email ?? '', iouReport, policy, transactions, diff --git a/src/libs/NextStepUtils.ts b/src/libs/NextStepUtils.ts index 150ffa0253a1b..f7d74e20e513d 100644 --- a/src/libs/NextStepUtils.ts +++ b/src/libs/NextStepUtils.ts @@ -196,7 +196,7 @@ function buildOptimisticNextStep(params: BuildNextStepNewParams): ReportNextStep nextStep = { messageKey: CONST.NEXT_STEP.MESSAGE_KEY.WAITING_TO_PAY, icon: CONST.NEXT_STEP.ICONS.HOURGLASS, - actorAccountID: isPayer({accountID: currentUserAccountIDParam, email: currentUserEmailParam}, report) ? currentUserAccountIDParam : -1, + actorAccountID: isPayer(currentUserAccountIDParam, currentUserEmailParam, report) ? currentUserAccountIDParam : -1, }; } break; @@ -214,16 +214,7 @@ function buildOptimisticNextStep(params: BuildNextStepNewParams): ReportNextStep // Generates an optimistic nextStep once a report has been approved case CONST.REPORT.STATUS_NUM.APPROVED: - if ( - isInvoiceReport(report) || - !isPayer( - { - accountID: currentUserAccountIDParam, - email: currentUserEmailParam, - }, - report, - ) - ) { + if (isInvoiceReport(report) || !isPayer(currentUserAccountIDParam, currentUserEmailParam, report)) { nextStep = nextStepNoActionRequired; break; } @@ -595,13 +586,7 @@ function buildNextStepNew(params: BuildNextStepNewParams): ReportNextStepDepreca { text: 'Waiting for ', }, - isPayer( - { - accountID: currentUserAccountIDParam, - email: currentUserEmailParam, - }, - report, - ) + isPayer(currentUserAccountIDParam, currentUserEmailParam, report) ? { text: `you`, type: 'strong', @@ -638,32 +623,14 @@ function buildNextStepNew(params: BuildNextStepNewParams): ReportNextStepDepreca // Generates an optimistic nextStep once a report has been approved case CONST.REPORT.STATUS_NUM.APPROVED: { - if ( - isInvoiceReport(report) || - !isPayer( - { - accountID: currentUserAccountIDParam, - email: currentUserEmailParam, - }, - report, - ) || - reimbursableSpend === 0 - ) { + if (isInvoiceReport(report) || !isPayer(currentUserAccountIDParam, currentUserEmailParam, report) || reimbursableSpend === 0) { optimisticNextStep = noActionRequired; break; } // Self review let payerMessage: Message; - if ( - isPayer( - { - accountID: currentUserAccountIDParam, - email: currentUserEmailParam, - }, - report, - ) - ) { + if (isPayer(currentUserAccountIDParam, currentUserEmailParam, report)) { payerMessage = {text: 'you', type: 'strong'}; } else if (reimburserAccountID === -1) { payerMessage = {text: 'an admin'}; diff --git a/src/libs/ReportPreviewActionUtils.ts b/src/libs/ReportPreviewActionUtils.ts index 02a8299ec2c4f..972ebec96fb53 100644 --- a/src/libs/ReportPreviewActionUtils.ts +++ b/src/libs/ReportPreviewActionUtils.ts @@ -74,12 +74,12 @@ function canApprove(report: Report, currentUserAccountID: number, policy?: Polic return isExpense && isProcessing && !!isApprovalEnabled && reportTransactions.length > 0 && isCurrentUserManager; } -function canPay(report: Report, isReportArchived: boolean, currentUserAccountID: number, policy?: Policy, invoiceReceiverPolicy?: Policy) { +function canPay(report: Report, isReportArchived: boolean, currentUserAccountID: number, currentUserEmail: string, policy?: Policy, invoiceReceiverPolicy?: Policy) { if (isReportArchived) { return false; } - const isReportPayer = isPayer(getSession(), report, false, policy); + const isReportPayer = isPayer(currentUserAccountID, currentUserEmail, report, false, policy); const isExpense = isExpenseReport(report); const isPaymentsEnabled = arePaymentsEnabled(policy); const isProcessing = isProcessingReport(report); @@ -152,6 +152,7 @@ function canExport(report: Report, policy?: Policy) { function getReportPreviewAction( isReportArchived: boolean, currentUserAccountID: number, + currentUserEmail: string, report: Report | undefined, policy: Policy | undefined, transactions: Transaction[], @@ -183,7 +184,7 @@ function getReportPreviewAction( if (canApprove(report, currentUserAccountID, policy, transactions)) { return CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE; } - if (canPay(report, isReportArchived, currentUserAccountID, policy, invoiceReceiverPolicy)) { + if (canPay(report, isReportArchived, currentUserAccountID, currentUserEmail, policy, invoiceReceiverPolicy)) { return CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY; } if (canExport(report, policy)) { diff --git a/src/libs/ReportPrimaryActionUtils.ts b/src/libs/ReportPrimaryActionUtils.ts index f16b80ace338c..0dd7e1169e792 100644 --- a/src/libs/ReportPrimaryActionUtils.ts +++ b/src/libs/ReportPrimaryActionUtils.ts @@ -139,12 +139,20 @@ function isApproveAction(report: Report, reportTransactions: Transaction[], poli return isProcessingReportUtils(report); } -function isPrimaryPayAction(report: Report, policy?: Policy, reportNameValuePairs?: ReportNameValuePairs, isChatReportArchived?: boolean, invoiceReceiverPolicy?: Policy) { +function isPrimaryPayAction( + report: Report, + currentUserAccountID: number, + currentUserEmail: string, + policy?: Policy, + reportNameValuePairs?: ReportNameValuePairs, + isChatReportArchived?: boolean, + invoiceReceiverPolicy?: Policy, +) { if (isArchivedReport(reportNameValuePairs) || isChatReportArchived) { return false; } const isExpenseReport = isExpenseReportUtils(report); - const isReportPayer = isPayer(getSession(), report, false, policy); + const isReportPayer = isPayer(currentUserAccountID, currentUserEmail, report, false, policy); const arePaymentsEnabled = arePaymentsEnabledUtils(policy); const isReportApproved = isReportApprovedUtils({report}); const isReportClosed = isClosedReportUtils(report); @@ -389,7 +397,8 @@ function getReportPrimaryAction(params: GetReportPrimaryActionParams): ValueOf> { const options: Array> = []; - if (isPrimaryPayAction(report, policy, reportNameValuePairs) && hasOnlyHeldExpenses(report?.reportID)) { + if (isPrimaryPayAction(report, currentUserAccountID, currentUserEmail, policy, reportNameValuePairs) && hasOnlyHeldExpenses(report?.reportID)) { options.push(CONST.REPORT.SECONDARY_ACTIONS.PAY); } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 6dfc7d5dd4fe8..62ae8731abece 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2639,11 +2639,11 @@ function isOneOnOneChat(report: OnyxEntry): boolean { * Checks if the current user is a payer of the expense */ -function isPayer(session: OnyxEntry, iouReport: OnyxEntry, onlyShowPayElsewhere = false, reportPolicy?: OnyxInputOrEntry) { +function isPayer(currentAccountID: number | undefined, currentUserEmail: string | undefined, iouReport: OnyxEntry, onlyShowPayElsewhere = false, reportPolicy?: OnyxInputOrEntry) { const policy = reportPolicy ?? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${iouReport?.policyID}`] ?? null; const policyType = policy?.type; const isAdmin = policyType !== CONST.POLICY.TYPE.PERSONAL && policy?.role === CONST.POLICY.ROLE.ADMIN; - const isManager = iouReport?.managerID === session?.accountID; + const isManager = iouReport?.managerID === currentAccountID; const reimbursementChoice = policy?.reimbursementChoice; if (isPaidGroupPolicy(iouReport)) { @@ -2653,7 +2653,7 @@ function isPayer(session: OnyxEntry, iouReport: OnyxEntry, only } // If we are the reimburser and the report is approved or we are the manager then we can pay it. - const isReimburser = session?.email === policy?.achAccount?.reimburser; + const isReimburser = currentUserEmail === policy?.achAccount?.reimburser; return isReimburser; } if (reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL || onlyShowPayElsewhere) { From f0a0f07bebbdeb2cb590ff15ad925c10cbdcfe54 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sun, 7 Dec 2025 13:26:41 +0530 Subject: [PATCH 05/16] more IOU cleanup --- src/libs/actions/IOU.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 76ce6d0731361..08a967aa2b8f7 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -10550,15 +10550,7 @@ function canIOUBePaid( return (invoiceReceiverPolicy ?? getPolicy(chatReport?.invoiceReceiver?.policyID))?.role === CONST.POLICY.ROLE.ADMIN; } - const isPayer = isPayerReportUtils( - { - email: currentUserEmail, - accountID: userAccountID, - }, - iouReport, - onlyShowPayElsewhere, - policy, - ); + const isPayer = isPayerReportUtils(userAccountID, currentUserEmail, iouReport, onlyShowPayElsewhere, policy); const isOpenExpenseReport = isOpenExpenseReportReportUtils(iouReport); @@ -10583,7 +10575,7 @@ function canIOUBePaid( } function canCancelPayment(iouReport: OnyxEntry, session: OnyxEntry) { - return isPayerReportUtils(session, iouReport) && (isSettled(iouReport) || iouReport?.isWaitingOnBankAccount) && isExpenseReport(iouReport); + return isPayerReportUtils(session?.accountID, session?.email, iouReport) && (isSettled(iouReport) || iouReport?.isWaitingOnBankAccount) && isExpenseReport(iouReport); } function canSubmitReport( From 59763e96feab94e5c0242d18d49dbb6a9606d237 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sun, 7 Dec 2025 13:30:40 +0530 Subject: [PATCH 06/16] More refactors --- src/components/MoneyReportHeader.tsx | 2 +- src/libs/ReportSecondaryActionUtils.ts | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 0bbdfb3e6444b..aef7035ea4a09 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -969,7 +969,7 @@ function MoneyReportHeader({ if (!moneyRequestReport) { return []; } - return getSecondaryExportReportActions(moneyRequestReport, policy, exportTemplates); + return getSecondaryExportReportActions(accountID, email ?? '', moneyRequestReport, policy, exportTemplates); }, [moneyRequestReport, policy, exportTemplates]); const connectedIntegrationName = connectedIntegration ? translate('workspace.accounting.connectionName', {connectionName: connectedIntegration}) : ''; diff --git a/src/libs/ReportSecondaryActionUtils.ts b/src/libs/ReportSecondaryActionUtils.ts index 053117be81900..c8ca638562951 100644 --- a/src/libs/ReportSecondaryActionUtils.ts +++ b/src/libs/ReportSecondaryActionUtils.ts @@ -276,7 +276,7 @@ function isUnapproveAction(currentUserLogin: string, report: Report, policy?: Po return isReportApprover; } -function isCancelPaymentAction(report: Report, reportTransactions: Transaction[], policy?: Policy): boolean { +function isCancelPaymentAction(currentAccountID: number, currentUserEmail: string, report: Report, reportTransactions: Transaction[], policy?: Policy): boolean { const isExpenseReport = isExpenseReportUtils(report); if (!isExpenseReport) { @@ -284,7 +284,7 @@ function isCancelPaymentAction(report: Report, reportTransactions: Transaction[] } const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN; - const isPayer = isPayerUtils(getSession(), report, false, policy); + const isPayer = isPayerUtils(currentAccountID, currentUserEmail, report, false, policy); if (!isAdmin || !isPayer) { return false; @@ -317,7 +317,7 @@ function isCancelPaymentAction(report: Report, reportTransactions: Transaction[] return isPaymentProcessing && !hasDailyNachaCutoffPassed; } -function isExportAction(report: Report, policy?: Policy): boolean { +function isExportAction(currentAccountID: number, currentUserEmail: string, report: Report, policy?: Policy): boolean { if (!policy) { return false; } @@ -341,7 +341,7 @@ function isExportAction(report: Report, policy?: Policy): boolean { } const isReportApproved = isReportApprovedUtils({report}); - const isReportPayer = isPayerUtils(getSession(), report, false, policy); + const isReportPayer = isPayerUtils(currentAccountID, currentUserEmail, report, false, policy); const arePaymentsEnabled = arePaymentsEnabledUtils(policy); const isReportClosed = isClosedReportUtils(report); @@ -359,7 +359,7 @@ function isExportAction(report: Report, policy?: Policy): boolean { return isAdmin && isReportFinished && syncEnabled; } -function isMarkAsExportedAction(report: Report, policy?: Policy): boolean { +function isMarkAsExportedAction(currentAccountID: number, currentUserEmail: string, report: Report, policy?: Policy): boolean { if (!policy) { return false; } @@ -382,7 +382,7 @@ function isMarkAsExportedAction(report: Report, policy?: Policy): boolean { return false; } - const isReportPayer = isPayerUtils(getSession(), report, false, policy); + const isReportPayer = isPayerUtils(currentAccountID, currentUserEmail, report, false, policy); const arePaymentsEnabled = arePaymentsEnabledUtils(policy); const isReportApproved = isReportApprovedUtils({report}); const isReportClosed = isClosedReportUtils(report); @@ -687,7 +687,7 @@ function getSecondaryReportActions({ options.push(CONST.REPORT.SECONDARY_ACTIONS.UNAPPROVE); } - if (isCancelPaymentAction(report, reportTransactions, policy)) { + if (isCancelPaymentAction(currentUserAccountID, currentUserEmail, report, reportTransactions, policy)) { options.push(CONST.REPORT.SECONDARY_ACTIONS.CANCEL_PAYMENT); } @@ -743,13 +743,19 @@ function getSecondaryReportActions({ return options; } -function getSecondaryExportReportActions(report: Report, policy?: Policy, exportTemplates: ExportTemplate[] = []): Array> { +function getSecondaryExportReportActions( + currentUserAccountID: number, + currentUserEmail: string, + report: Report, + policy?: Policy, + exportTemplates: ExportTemplate[] = [], +): Array> { const options: Array> = []; - if (isExportAction(report, policy)) { + if (isExportAction(currentUserAccountID, currentUserEmail, report, policy)) { options.push(CONST.REPORT.EXPORT_OPTIONS.EXPORT_TO_INTEGRATION); } - if (isMarkAsExportedAction(report, policy)) { + if (isMarkAsExportedAction(currentUserAccountID, currentUserEmail, report, policy)) { options.push(CONST.REPORT.EXPORT_OPTIONS.MARK_AS_EXPORTED); } From 14a8fa33b3397ff3fc93aac5491589b70f692f22 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sun, 7 Dec 2025 13:32:39 +0530 Subject: [PATCH 07/16] update tests --- tests/actions/ReportPreviewActionUtilsTest.ts | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/tests/actions/ReportPreviewActionUtilsTest.ts b/tests/actions/ReportPreviewActionUtilsTest.ts index 6531708e56191..84a2da76504ad 100644 --- a/tests/actions/ReportPreviewActionUtilsTest.ts +++ b/tests/actions/ReportPreviewActionUtilsTest.ts @@ -71,7 +71,7 @@ describe('getReportPreviewAction', () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report); const policy = createRandomPolicy(0, CONST.POLICY.TYPE.PERSONAL); - expect(getReportPreviewAction(false, CURRENT_USER_ACCOUNT_ID, report, policy, [])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.ADD_EXPENSE); + expect(getReportPreviewAction(false, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.ADD_EXPENSE); }); it('canSubmit should return true for expense preview report with manual submit', async () => { @@ -103,7 +103,7 @@ describe('getReportPreviewAction', () => { await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT); + expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT); }); it('canSubmit should return true for open report in instant submit policy with no approvers', async () => { @@ -136,7 +136,7 @@ describe('getReportPreviewAction', () => { // Simulate how components use a hook to pass the isReportArchived parameter const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT); + expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT); }); it('canSubmit should return false for expense preview report with only pending transactions', async () => { @@ -169,7 +169,7 @@ describe('getReportPreviewAction', () => { await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); + expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); }); describe('canApprove', () => { @@ -200,7 +200,9 @@ describe('getReportPreviewAction', () => { const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE); + expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe( + CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE, + ); }); it('should return false for report with scanning expenses', async () => { @@ -228,7 +230,7 @@ describe('getReportPreviewAction', () => { }, } as unknown as Transaction; - expect(getReportPreviewAction(false, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); + expect(getReportPreviewAction(false, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); }); it('should return false for report with pending expenses', async () => { @@ -257,7 +259,7 @@ describe('getReportPreviewAction', () => { date: '2025-01-01', } as unknown as Transaction; - expect(getReportPreviewAction(false, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); + expect(getReportPreviewAction(false, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); }); }); @@ -288,7 +290,9 @@ describe('getReportPreviewAction', () => { const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE); + expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe( + CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE, + ); }); it('canPay should return true for expense report with payments enabled', async () => { @@ -313,7 +317,7 @@ describe('getReportPreviewAction', () => { const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY); + expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY); }); it('canPay should return false for Expense report with zero total amount', async () => { @@ -339,7 +343,7 @@ describe('getReportPreviewAction', () => { await waitForBatchedUpdatesWithAct(); // Should not show PAY button for zero amount Expenses - expect(getReportPreviewAction(false, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); + expect(getReportPreviewAction(false, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); }); it('canPay should return true for submitted invoice', async () => { @@ -368,7 +372,9 @@ describe('getReportPreviewAction', () => { const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction], invoiceReceiverPolicy)).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY); + expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction], invoiceReceiverPolicy)).toBe( + CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY, + ); }); it('getReportPreviewAction should return VIEW action for zero value invoice', async () => { @@ -413,7 +419,7 @@ describe('getReportPreviewAction', () => { const {result: isReportArchived} = renderHook(() => useReportIsArchived(report.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction], invoiceReceiverPolicy)).toBe( + expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction], invoiceReceiverPolicy)).toBe( CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW, ); }); @@ -448,7 +454,9 @@ describe('getReportPreviewAction', () => { } as unknown as Transaction; const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction], invoiceReceiverPolicy)).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY); + expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction], invoiceReceiverPolicy)).toBe( + CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY, + ); }); it('getReportPreviewAction should return VIEW action for invoice when the chat report is archived', async () => { @@ -476,7 +484,9 @@ describe('getReportPreviewAction', () => { const {result: isChatReportArchived} = renderHook(() => useReportIsArchived(report?.chatReportID)); await waitForBatchedUpdatesWithAct(); // Then the getReportPreviewAction should return the View action - expect(getReportPreviewAction(isChatReportArchived.current, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction], undefined)).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); + expect(getReportPreviewAction(isChatReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction], undefined)).toBe( + CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW, + ); }); it('canExport should return true for finished reports', async () => { @@ -499,6 +509,8 @@ describe('getReportPreviewAction', () => { const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.EXPORT_TO_ACCOUNTING); + expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe( + CONST.REPORT.REPORT_PREVIEW_ACTIONS.EXPORT_TO_ACCOUNTING, + ); }); }); From f440dd0593819bfe279c89053594cbf69e7ddd67 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sun, 7 Dec 2025 13:34:13 +0530 Subject: [PATCH 08/16] fix formatting --- src/libs/Firebase/utils.ts | 4 ++-- src/libs/ReportUtils.ts | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/libs/Firebase/utils.ts b/src/libs/Firebase/utils.ts index a122ed0082db6..704d96b3de862 100644 --- a/src/libs/Firebase/utils.ts +++ b/src/libs/Firebase/utils.ts @@ -1,8 +1,8 @@ // We have opted for `Onyx.connectWithoutView` here as this logic is strictly non-UI in nature. -import Onyx, { OnyxEntry } from 'react-native-onyx'; +import Onyx, {OnyxEntry} from 'react-native-onyx'; import ONYXKEYS from '@src/ONYXKEYS'; +import {Session} from '@src/types/onyx'; import type {PerfAttributes} from './types'; -import { Session } from '@src/types/onyx'; let reportsCount = 0; Onyx.connectWithoutView({ diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 62ae8731abece..a7ee1fc0bdfef 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2639,7 +2639,13 @@ function isOneOnOneChat(report: OnyxEntry): boolean { * Checks if the current user is a payer of the expense */ -function isPayer(currentAccountID: number | undefined, currentUserEmail: string | undefined, iouReport: OnyxEntry, onlyShowPayElsewhere = false, reportPolicy?: OnyxInputOrEntry) { +function isPayer( + currentAccountID: number | undefined, + currentUserEmail: string | undefined, + iouReport: OnyxEntry, + onlyShowPayElsewhere = false, + reportPolicy?: OnyxInputOrEntry, +) { const policy = reportPolicy ?? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${iouReport?.policyID}`] ?? null; const policyType = policy?.type; const isAdmin = policyType !== CONST.POLICY.TYPE.PERSONAL && policy?.role === CONST.POLICY.ROLE.ADMIN; From 9c689ec2d4401c55672809304b546c542b44ca7d Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sun, 7 Dec 2025 13:48:55 +0530 Subject: [PATCH 09/16] more fixes --- src/components/MoneyReportHeader.tsx | 2 +- src/libs/Firebase/utils.ts | 5 ++-- src/libs/ReportPreviewActionUtils.ts | 1 - src/libs/ReportPrimaryActionUtils.ts | 1 - src/libs/ReportUtils.ts | 5 ++-- src/libs/actions/IOU.ts | 1 - tests/unit/ReportSecondaryActionUtilsTest.ts | 24 ++++++++++---------- tests/unit/ReportUtilsTest.ts | 6 ++--- 8 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index aef7035ea4a09..d07e8abd960f8 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -970,7 +970,7 @@ function MoneyReportHeader({ return []; } return getSecondaryExportReportActions(accountID, email ?? '', moneyRequestReport, policy, exportTemplates); - }, [moneyRequestReport, policy, exportTemplates]); + }, [moneyRequestReport, accountID, email, policy, exportTemplates]); const connectedIntegrationName = connectedIntegration ? translate('workspace.accounting.connectionName', {connectionName: connectedIntegration}) : ''; const unapproveWarningText = useMemo( diff --git a/src/libs/Firebase/utils.ts b/src/libs/Firebase/utils.ts index 704d96b3de862..f7bf4d89a2609 100644 --- a/src/libs/Firebase/utils.ts +++ b/src/libs/Firebase/utils.ts @@ -1,7 +1,8 @@ // We have opted for `Onyx.connectWithoutView` here as this logic is strictly non-UI in nature. -import Onyx, {OnyxEntry} from 'react-native-onyx'; +import Onyx from 'react-native-onyx'; +import type {OnyxEntry} from 'react-native-onyx'; import ONYXKEYS from '@src/ONYXKEYS'; -import {Session} from '@src/types/onyx'; +import type {Session} from '@src/types/onyx'; import type {PerfAttributes} from './types'; let reportsCount = 0; diff --git a/src/libs/ReportPreviewActionUtils.ts b/src/libs/ReportPreviewActionUtils.ts index 972ebec96fb53..566c007b57efa 100644 --- a/src/libs/ReportPreviewActionUtils.ts +++ b/src/libs/ReportPreviewActionUtils.ts @@ -18,7 +18,6 @@ import { isReportApproved, isSettled, } from './ReportUtils'; -import {getSession} from './SessionUtils'; import {isPending, isScanning} from './TransactionUtils'; function canSubmit(report: Report, isReportArchived: boolean, currentUserAccountID: number, policy?: Policy, transactions?: Transaction[]) { diff --git a/src/libs/ReportPrimaryActionUtils.ts b/src/libs/ReportPrimaryActionUtils.ts index 0dd7e1169e792..403d2d17f8e6b 100644 --- a/src/libs/ReportPrimaryActionUtils.ts +++ b/src/libs/ReportPrimaryActionUtils.ts @@ -35,7 +35,6 @@ import { isReportManager, isSettled, } from './ReportUtils'; -import {getSession} from './SessionUtils'; import { allHavePendingRTERViolation, getTransactionViolations, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a7ee1fc0bdfef..43232862a3f7f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -57,7 +57,6 @@ import type { ReportNameValuePairs, ReportViolationName, ReportViolations, - Session, Task, Transaction, TransactionViolation, @@ -2641,7 +2640,7 @@ function isOneOnOneChat(report: OnyxEntry): boolean { function isPayer( currentAccountID: number | undefined, - currentUserEmail: string | undefined, + currentUserEmailParm: string | undefined, iouReport: OnyxEntry, onlyShowPayElsewhere = false, reportPolicy?: OnyxInputOrEntry, @@ -2659,7 +2658,7 @@ function isPayer( } // If we are the reimburser and the report is approved or we are the manager then we can pay it. - const isReimburser = currentUserEmail === policy?.achAccount?.reimburser; + const isReimburser = currentUserEmailParm === policy?.achAccount?.reimburser; return isReimburser; } if (reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL || onlyShowPayElsewhere) { diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 08a967aa2b8f7..4a48411320253 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -203,7 +203,6 @@ import { } from '@libs/ReportUtils'; import {getCurrentSearchQueryJSON} from '@libs/SearchQueryUtils'; import {getSuggestedSearches} from '@libs/SearchUIUtils'; -import {getSession} from '@libs/SessionUtils'; import playSound, {SOUNDS} from '@libs/Sound'; import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils'; import {startSpan} from '@libs/telemetry/activeSpans'; diff --git a/tests/unit/ReportSecondaryActionUtilsTest.ts b/tests/unit/ReportSecondaryActionUtilsTest.ts index 380d639e673e4..64ddb208bc337 100644 --- a/tests/unit/ReportSecondaryActionUtilsTest.ts +++ b/tests/unit/ReportSecondaryActionUtilsTest.ts @@ -1674,7 +1674,7 @@ describe('getSecondaryExportReportActions', () => { const policy = {} as unknown as Policy; const result = [CONST.REPORT.EXPORT_OPTIONS.DOWNLOAD_CSV]; - expect(getSecondaryExportReportActions(report, policy)).toEqual(result); + expect(getSecondaryExportReportActions(SESSION.accountID, SESSION.email, report, policy)).toEqual(result); }); it('should include export templates when provided', () => { @@ -1705,7 +1705,7 @@ describe('getSecondaryExportReportActions', () => { ]; const result = [CONST.REPORT.EXPORT_OPTIONS.DOWNLOAD_CSV, 'All Data - expense level', 'All Data - report level', 'Custom Template']; - expect(getSecondaryExportReportActions(report, policy, exportTemplates)).toEqual(result); + expect(getSecondaryExportReportActions(SESSION.accountID, SESSION.email, report, policy, exportTemplates)).toEqual(result); }); it('does not include EXPORT option for invoice reports', async () => { @@ -1721,7 +1721,7 @@ describe('getSecondaryExportReportActions', () => { } as unknown as Policy; await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report); - const result = getSecondaryExportReportActions(report, policy); + const result = getSecondaryExportReportActions(SESSION.accountID, SESSION.email, report, policy); expect(result.includes(CONST.REPORT.EXPORT_OPTIONS.EXPORT_TO_INTEGRATION)).toBe(false); }); @@ -1740,7 +1740,7 @@ describe('getSecondaryExportReportActions', () => { connections: {[CONST.POLICY.CONNECTIONS.NAME.QBD]: {}}, } as unknown as Policy; - const result = getSecondaryExportReportActions(report, policy); + const result = getSecondaryExportReportActions(SESSION.accountID, SESSION.email, report, policy); expect(result.includes(CONST.REPORT.EXPORT_OPTIONS.EXPORT_TO_INTEGRATION)).toBe(true); }); @@ -1767,7 +1767,7 @@ describe('getSecondaryExportReportActions', () => { }, ]; - const result = getSecondaryExportReportActions(report, policy, exportTemplates); + const result = getSecondaryExportReportActions(SESSION.accountID, SESSION.email, report, policy, exportTemplates); expect(result.includes(CONST.REPORT.EXPORT_OPTIONS.EXPORT_TO_INTEGRATION)).toBe(true); expect(result.includes(CONST.REPORT.EXPORT_OPTIONS.DOWNLOAD_CSV)).toBe(true); expect(result.includes('All Data - expense level')).toBe(true); @@ -1786,7 +1786,7 @@ describe('getSecondaryExportReportActions', () => { connections: {[CONST.POLICY.CONNECTIONS.NAME.QBD]: {config: {autosync: {enabled: true}}}}, } as unknown as Policy; - const result = getSecondaryExportReportActions(report, policy); + const result = getSecondaryExportReportActions(SESSION.accountID, SESSION.email, report, policy); expect(result.includes(CONST.REPORT.EXPORT_OPTIONS.EXPORT_TO_INTEGRATION)).toBe(true); }); @@ -1801,7 +1801,7 @@ describe('getSecondaryExportReportActions', () => { } as unknown as Policy; await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report); - const result = getSecondaryExportReportActions(report, policy); + const result = getSecondaryExportReportActions(SESSION.accountID, SESSION.email, report, policy); expect(result.includes(CONST.REPORT.EXPORT_OPTIONS.MARK_AS_EXPORTED)).toBe(true); }); @@ -1817,7 +1817,7 @@ describe('getSecondaryExportReportActions', () => { connections: {[CONST.POLICY.CONNECTIONS.NAME.QBD]: {config: {export: {exporter: EMPLOYEE_EMAIL}, autoSync: {enabled: false}}}}, } as unknown as Policy; - const result = getSecondaryExportReportActions(report, policy); + const result = getSecondaryExportReportActions(SESSION.accountID, SESSION.email, report, policy); expect(result.includes(CONST.REPORT.EXPORT_OPTIONS.MARK_AS_EXPORTED)).toBe(true); }); @@ -1835,7 +1835,7 @@ describe('getSecondaryExportReportActions', () => { connections: {[CONST.POLICY.CONNECTIONS.NAME.QBD]: {}}, } as unknown as Policy; - const result = getSecondaryExportReportActions(report, policy); + const result = getSecondaryExportReportActions(SESSION.accountID, SESSION.email, report, policy); expect(result.includes(CONST.REPORT.EXPORT_OPTIONS.MARK_AS_EXPORTED)).toBe(true); }); @@ -1852,7 +1852,7 @@ describe('getSecondaryExportReportActions', () => { connections: {[CONST.POLICY.CONNECTIONS.NAME.QBD]: {config: {autosync: {enabled: true}}}}, } as unknown as Policy; - const result = getSecondaryExportReportActions(report, policy); + const result = getSecondaryExportReportActions(SESSION.accountID, SESSION.email, report, policy); expect(result.includes(CONST.REPORT.EXPORT_OPTIONS.MARK_AS_EXPORTED)).toBe(true); }); @@ -1868,7 +1868,7 @@ describe('getSecondaryExportReportActions', () => { connections: {[CONST.POLICY.CONNECTIONS.NAME.QBD]: {config: {export: {exporter: EMPLOYEE_EMAIL}, autoSync: {enabled: false}}}}, } as unknown as Policy; - const result = getSecondaryExportReportActions(report, policy); + const result = getSecondaryExportReportActions(SESSION.accountID, SESSION.email, report, policy); expect(result.includes(CONST.REPORT.EXPORT_OPTIONS.MARK_AS_EXPORTED)).toBe(true); }); @@ -1885,7 +1885,7 @@ describe('getSecondaryExportReportActions', () => { role: CONST.POLICY.ROLE.ADMIN, } as unknown as Policy; - const result = getSecondaryExportReportActions(report, policy); + const result = getSecondaryExportReportActions(SESSION.accountID, SESSION.email, report, policy); expect(result.includes(CONST.REPORT.EXPORT_OPTIONS.MARK_AS_EXPORTED)).toBe(true); }); diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index d7cf70fd0cffc..2656f9286c27e 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -5520,11 +5520,11 @@ describe('ReportUtils', () => { afterAll(() => Onyx.clear()); it('should return false for admin of a group policy with reimbursement enabled and report not approved', () => { - expect(isPayer({email: currentUserEmail, accountID: currentUserAccountID}, unapprovedReport, false)).toBe(false); + expect(isPayer(currentUserAccountID, currentUserEmail, unapprovedReport, false)).toBe(false); }); it('should return false for non-admin of a group policy', () => { - expect(isPayer({email: currentUserEmail, accountID: currentUserAccountID}, approvedReport, false)).toBe(false); + expect(isPayer(currentUserAccountID, currentUserEmail, approvedReport, false)).toBe(false); }); it('should return true for a reimburser of a group policy on a closed report', async () => { @@ -5539,7 +5539,7 @@ describe('ReportUtils', () => { policyID: policyTest.id, }; - expect(isPayer({email: currentUserEmail, accountID: currentUserAccountID}, closedReport, false)).toBe(true); + expect(isPayer(currentUserAccountID, currentUserEmail, closedReport, false)).toBe(true); }); }); describe('buildReportNameFromParticipantNames', () => { From 54ba8f31b178703e9f2239d85a9a402474a56cb6 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sun, 7 Dec 2025 14:04:55 +0530 Subject: [PATCH 10/16] remove some warnings --- .../MoneyRequestReportPreviewContent.tsx | 13 +++++++------ src/libs/ReportSecondaryActionUtils.ts | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 31e5cfc1cc131..e6a6789917e3a 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -502,16 +502,17 @@ function MoneyRequestReportPreviewContent({ isSubmittingAnimationRunning, ); }, [ - isPaidAnimationRunning, - isApprovedAnimationRunning, - isSubmittingAnimationRunning, + isIouReportArchived, + isChatReportArchived, + currentUserDetails.accountID, + currentUserDetails.email, iouReport, policy, transactions, - isIouReportArchived, invoiceReceiverPolicy, - isChatReportArchived, - currentUserDetails.accountID, + isPaidAnimationRunning, + isApprovedAnimationRunning, + isSubmittingAnimationRunning, ]); const addExpenseDropdownOptions = useMemo( diff --git a/src/libs/ReportSecondaryActionUtils.ts b/src/libs/ReportSecondaryActionUtils.ts index c8ca638562951..b8b07741b94be 100644 --- a/src/libs/ReportSecondaryActionUtils.ts +++ b/src/libs/ReportSecondaryActionUtils.ts @@ -52,7 +52,6 @@ import { isSettled, isWorkspaceEligibleForReportChange, } from './ReportUtils'; -import {getSession} from './SessionUtils'; import { allHavePendingRTERViolation, getOriginalTransactionWithSplitInfo, From 3929a0a82d3b2964a8c695f120646e59d27be1c6 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sun, 7 Dec 2025 14:06:13 +0530 Subject: [PATCH 11/16] Remove session --- src/libs/SessionUtils.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/libs/SessionUtils.ts b/src/libs/SessionUtils.ts index 237ae33adb80f..db493fa0961b0 100644 --- a/src/libs/SessionUtils.ts +++ b/src/libs/SessionUtils.ts @@ -1,8 +1,6 @@ import Onyx from 'react-native-onyx'; -import type {OnyxEntry} from 'react-native-onyx'; import CONFIG from '@src/CONFIG'; import ONYXKEYS from '@src/ONYXKEYS'; -import type * as OnyxTypes from '@src/types/onyx'; const NEW_PARTNER_USER_ID_PREFIX = 'expensify.cash-'; @@ -31,14 +29,12 @@ function isLoggingInAsNewUser(transitionURL?: string, sessionEmail?: string): bo } let loggedInDuringSession: boolean | undefined; -let currentSession: OnyxEntry; // To tell if the user logged in during this session we will check the value of session.authToken once when the app's JS inits. When the user logs out // we can reset this flag so that it can be updated again. Onyx.connectWithoutView({ key: ONYXKEYS.SESSION, callback: (session) => { - currentSession = session; if (loggedInDuringSession) { return; } @@ -60,10 +56,6 @@ function didUserLogInDuringSession() { return !!loggedInDuringSession; } -function getSession() { - return currentSession; -} - function checkIfShouldUseNewPartnerName(partnerUserID?: string): boolean { if (!CONFIG.IS_HYBRID_APP) { return true; @@ -78,4 +70,4 @@ function checkIfShouldUseNewPartnerName(partnerUserID?: string): boolean { return false; } -export {isLoggingInAsNewUser, didUserLogInDuringSession, resetDidUserLogInDuringSession, getSession, checkIfShouldUseNewPartnerName}; +export {isLoggingInAsNewUser, didUserLogInDuringSession, resetDidUserLogInDuringSession, checkIfShouldUseNewPartnerName}; From ee3b2a24904218c195ff533d7b2ea6f48761263d Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Sun, 21 Dec 2025 22:07:32 +0530 Subject: [PATCH 12/16] Fix tests --- src/hooks/useTodos.ts | 6 ++++-- tests/actions/ReportPreviewActionUtilsTest.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hooks/useTodos.ts b/src/hooks/useTodos.ts index eea23c0df95da..cc5859a3c6d43 100644 --- a/src/hooks/useTodos.ts +++ b/src/hooks/useTodos.ts @@ -3,6 +3,7 @@ import {isApproveAction, isExportAction, isPrimaryPayAction, isSubmitAction} fro import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Report, Transaction} from '@src/types/onyx'; +import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; import useOnyx from './useOnyx'; export default function useTodos() { @@ -11,6 +12,7 @@ export default function useTodos() { const [allReportNameValuePairs] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, {canBeMissing: false}); const [allTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {canBeMissing: false}); const [allReportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, {canBeMissing: false}); + const {email = '', accountID} = useCurrentUserPersonalDetails(); return useMemo(() => { const reportsToSubmit: Report[] = []; @@ -48,7 +50,7 @@ export default function useTodos() { if (isApproveAction(report, reportTransactions, policy)) { reportsToApprove.push(report); } - if (isPrimaryPayAction(report, policy, reportNameValuePair)) { + if (isPrimaryPayAction(report, accountID, email, policy, reportNameValuePair)) { reportsToPay.push(report); } if (isExportAction(report, policy, reportActions)) { @@ -57,5 +59,5 @@ export default function useTodos() { } return {reportsToSubmit, reportsToApprove, reportsToPay, reportsToExport}; - }, [allReports, allPolicies, allReportNameValuePairs, allTransactions, allReportActions]); + }, [allReports, allTransactions, allPolicies, allReportNameValuePairs, allReportActions, accountID, email]); } diff --git a/tests/actions/ReportPreviewActionUtilsTest.ts b/tests/actions/ReportPreviewActionUtilsTest.ts index d5f5b00adb0b7..1231d65cdbda9 100644 --- a/tests/actions/ReportPreviewActionUtilsTest.ts +++ b/tests/actions/ReportPreviewActionUtilsTest.ts @@ -206,7 +206,7 @@ describe('getReportPreviewAction', () => { await waitForBatchedUpdatesWithAct(); expect( - getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, report, policy, [transaction], undefined, undefined, undefined, undefined, { + getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction], undefined, undefined, undefined, undefined, { currentUserEmail: CURRENT_USER_EMAIL, violations, }), From 64e93a776a0b58bf51d082574283b7f00233a483 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Mon, 22 Dec 2025 22:57:38 +0530 Subject: [PATCH 13/16] Covert params to object --- .../MoneyRequestReportPreviewContent.tsx | 14 +- src/libs/ReportPreviewActionUtils.ts | 38 ++-- tests/actions/ReportPreviewActionUtilsTest.ts | 192 +++++++++++++++--- 3 files changed, 193 insertions(+), 51 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 6b5be51d54a9b..c67304a1eb0f6 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -516,19 +516,19 @@ function MoneyRequestReportPreviewContent({ }, [iouReportID]); const reportPreviewAction = useMemo(() => { - return getReportPreviewAction( - isIouReportArchived || isChatReportArchived, - currentUserDetails.accountID, - currentUserDetails.email ?? '', - iouReport, + return getReportPreviewAction({ + isReportArchived: isIouReportArchived || isChatReportArchived, + currentUserAccountID: currentUserDetails.accountID, + currentUserEmail: currentUserDetails.email ?? '', + report: iouReport, policy, transactions, invoiceReceiverPolicy, isPaidAnimationRunning, isApprovedAnimationRunning, isSubmittingAnimationRunning, - {currentUserEmail, violations: transactionViolations}, - ); + violationsData: {currentUserEmail, violations: transactionViolations}, + }); }, [ isIouReportArchived, isChatReportArchived, diff --git a/src/libs/ReportPreviewActionUtils.ts b/src/libs/ReportPreviewActionUtils.ts index e38a8ffd61e46..ae7e99e7e55da 100644 --- a/src/libs/ReportPreviewActionUtils.ts +++ b/src/libs/ReportPreviewActionUtils.ts @@ -165,19 +165,31 @@ function canExport(report: Report, policy?: Policy) { return isApproved || isReimbursed || isClosed; } -function getReportPreviewAction( - isReportArchived: boolean, - currentUserAccountID: number, - currentUserEmail: string, - report: Report | undefined, - policy: Policy | undefined, - transactions: Transaction[], - invoiceReceiverPolicy?: Policy, - isPaidAnimationRunning?: boolean, - isApprovedAnimationRunning?: boolean, - isSubmittingAnimationRunning?: boolean, - violationsData?: {currentUserEmail?: string; violations?: OnyxCollection}, -): ValueOf { +function getReportPreviewAction({ + isReportArchived, + currentUserAccountID, + currentUserEmail, + report, + policy, + transactions, + invoiceReceiverPolicy, + isPaidAnimationRunning, + isApprovedAnimationRunning, + isSubmittingAnimationRunning, + violationsData, +}: { + isReportArchived: boolean; + currentUserAccountID: number; + currentUserEmail: string; + report: Report | undefined; + policy: Policy | undefined; + transactions: Transaction[]; + invoiceReceiverPolicy?: Policy; + isPaidAnimationRunning?: boolean; + isApprovedAnimationRunning?: boolean; + isSubmittingAnimationRunning?: boolean; + violationsData?: {currentUserEmail?: string; violations?: OnyxCollection}; +}): ValueOf { if (!report) { return CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW; } diff --git a/tests/actions/ReportPreviewActionUtilsTest.ts b/tests/actions/ReportPreviewActionUtilsTest.ts index 1231d65cdbda9..0f2a231f4fe34 100644 --- a/tests/actions/ReportPreviewActionUtilsTest.ts +++ b/tests/actions/ReportPreviewActionUtilsTest.ts @@ -71,7 +71,9 @@ describe('getReportPreviewAction', () => { await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, report); const policy = createRandomPolicy(0, CONST.POLICY.TYPE.PERSONAL); - expect(getReportPreviewAction(false, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.ADD_EXPENSE); + expect(getReportPreviewAction({isReportArchived: false, currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, report, policy, transactions: []})).toBe( + CONST.REPORT.REPORT_PREVIEW_ACTIONS.ADD_EXPENSE, + ); }); it('canSubmit should return true for expense preview report with manual submit', async () => { @@ -100,7 +102,16 @@ describe('getReportPreviewAction', () => { await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT); + expect( + getReportPreviewAction({ + isReportArchived: isReportArchived.current, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT); }); it('canSubmit should return true for open report in instant submit policy with no approvers', async () => { @@ -130,7 +141,16 @@ describe('getReportPreviewAction', () => { // Simulate how components use a hook to pass the isReportArchived parameter const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT); + expect( + getReportPreviewAction({ + isReportArchived: isReportArchived.current, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT); }); it('canSubmit should return false for expense preview report with only pending transactions', async () => { @@ -163,7 +183,16 @@ describe('getReportPreviewAction', () => { await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); + expect( + getReportPreviewAction({ + isReportArchived: isReportArchived.current, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); }); it('canSubmit should return false for expense preview report with smartscan failed violation', async () => { @@ -206,9 +235,21 @@ describe('getReportPreviewAction', () => { await waitForBatchedUpdatesWithAct(); expect( - getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction], undefined, undefined, undefined, undefined, { + getReportPreviewAction({ + isReportArchived: isReportArchived.current, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, currentUserEmail: CURRENT_USER_EMAIL, - violations, + report, + policy, + transactions: [transaction], + invoiceReceiverPolicy: undefined, + isPaidAnimationRunning: undefined, + isApprovedAnimationRunning: undefined, + isSubmittingAnimationRunning: undefined, + violationsData: { + currentUserEmail: CURRENT_USER_EMAIL, + violations, + }, }), ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); }); @@ -238,9 +279,16 @@ describe('getReportPreviewAction', () => { const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe( - CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE, - ); + expect( + getReportPreviewAction({ + isReportArchived: isReportArchived.current, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE); }); it('should return false for report with scanning expenses', async () => { @@ -268,7 +316,16 @@ describe('getReportPreviewAction', () => { }, } as unknown as Transaction; - expect(getReportPreviewAction(false, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); + expect( + getReportPreviewAction({ + isReportArchived: false, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); }); it('should return false for report with pending expenses', async () => { @@ -297,7 +354,16 @@ describe('getReportPreviewAction', () => { date: '2025-01-01', } as unknown as Transaction; - expect(getReportPreviewAction(false, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); + expect( + getReportPreviewAction({ + isReportArchived: false, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); }); }); @@ -325,9 +391,16 @@ describe('getReportPreviewAction', () => { const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe( - CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE, - ); + expect( + getReportPreviewAction({ + isReportArchived: isReportArchived.current, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.APPROVE); }); it('canPay should return true for expense report with payments enabled', async () => { @@ -352,7 +425,16 @@ describe('getReportPreviewAction', () => { const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY); + expect( + getReportPreviewAction({ + isReportArchived: isReportArchived.current, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY); }); it('canPay should return false for Expense report with zero total amount', async () => { @@ -378,7 +460,16 @@ describe('getReportPreviewAction', () => { await waitForBatchedUpdatesWithAct(); // Should not show PAY button for zero amount Expenses - expect(getReportPreviewAction(false, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); + expect( + getReportPreviewAction({ + isReportArchived: false, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); }); it('canPay should return true for submitted invoice', async () => { @@ -407,9 +498,17 @@ describe('getReportPreviewAction', () => { const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction], invoiceReceiverPolicy)).toBe( - CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY, - ); + expect( + getReportPreviewAction({ + isReportArchived: isReportArchived.current, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + invoiceReceiverPolicy, + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY); }); it('getReportPreviewAction should return VIEW action for zero value invoice', async () => { @@ -454,9 +553,17 @@ describe('getReportPreviewAction', () => { const {result: isReportArchived} = renderHook(() => useReportIsArchived(report.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction], invoiceReceiverPolicy)).toBe( - CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW, - ); + expect( + getReportPreviewAction({ + isReportArchived: isReportArchived.current, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + invoiceReceiverPolicy, + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); }); it('canPay should return false for archived invoice', async () => { @@ -489,9 +596,17 @@ describe('getReportPreviewAction', () => { } as unknown as Transaction; const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction], invoiceReceiverPolicy)).toBe( - CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY, - ); + expect( + getReportPreviewAction({ + isReportArchived: isReportArchived.current, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + invoiceReceiverPolicy, + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.PAY); }); it('getReportPreviewAction should return VIEW action for invoice when the chat report is archived', async () => { @@ -519,9 +634,17 @@ describe('getReportPreviewAction', () => { const {result: isChatReportArchived} = renderHook(() => useReportIsArchived(report?.chatReportID)); await waitForBatchedUpdatesWithAct(); // Then the getReportPreviewAction should return the View action - expect(getReportPreviewAction(isChatReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction], undefined)).toBe( - CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW, - ); + expect( + getReportPreviewAction({ + isReportArchived: isChatReportArchived.current, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + invoiceReceiverPolicy: undefined, + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); }); it('canExport should return true for finished reports', async () => { @@ -544,8 +667,15 @@ describe('getReportPreviewAction', () => { const {result: isReportArchived} = renderHook(() => useReportIsArchived(report?.parentReportID)); await waitForBatchedUpdatesWithAct(); - expect(getReportPreviewAction(isReportArchived.current, CURRENT_USER_ACCOUNT_ID, CURRENT_USER_EMAIL, report, policy, [transaction])).toBe( - CONST.REPORT.REPORT_PREVIEW_ACTIONS.EXPORT_TO_ACCOUNTING, - ); + expect( + getReportPreviewAction({ + isReportArchived: isReportArchived.current, + currentUserAccountID: CURRENT_USER_ACCOUNT_ID, + currentUserEmail: CURRENT_USER_EMAIL, + report, + policy, + transactions: [transaction], + }), + ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.EXPORT_TO_ACCOUNTING); }); }); From 673d42d97e96231137167948087d2a76eb8e1024 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Mon, 22 Dec 2025 22:59:04 +0530 Subject: [PATCH 14/16] Fix params --- .../MoneyRequestReportPreviewContent.tsx | 3 +-- src/libs/ReportPreviewActionUtils.ts | 2 +- tests/actions/ReportPreviewActionUtilsTest.ts | 5 +---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index c67304a1eb0f6..d92a32adb556c 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -527,7 +527,7 @@ function MoneyRequestReportPreviewContent({ isPaidAnimationRunning, isApprovedAnimationRunning, isSubmittingAnimationRunning, - violationsData: {currentUserEmail, violations: transactionViolations}, + violationsData: transactionViolations, }); }, [ isIouReportArchived, @@ -541,7 +541,6 @@ function MoneyRequestReportPreviewContent({ isPaidAnimationRunning, isApprovedAnimationRunning, isSubmittingAnimationRunning, - currentUserEmail, transactionViolations, ]); diff --git a/src/libs/ReportPreviewActionUtils.ts b/src/libs/ReportPreviewActionUtils.ts index ae7e99e7e55da..677d985aa673e 100644 --- a/src/libs/ReportPreviewActionUtils.ts +++ b/src/libs/ReportPreviewActionUtils.ts @@ -188,7 +188,7 @@ function getReportPreviewAction({ isPaidAnimationRunning?: boolean; isApprovedAnimationRunning?: boolean; isSubmittingAnimationRunning?: boolean; - violationsData?: {currentUserEmail?: string; violations?: OnyxCollection}; + violationsData?: OnyxCollection; }): ValueOf { if (!report) { return CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW; diff --git a/tests/actions/ReportPreviewActionUtilsTest.ts b/tests/actions/ReportPreviewActionUtilsTest.ts index 0f2a231f4fe34..491fc278c5c00 100644 --- a/tests/actions/ReportPreviewActionUtilsTest.ts +++ b/tests/actions/ReportPreviewActionUtilsTest.ts @@ -246,10 +246,7 @@ describe('getReportPreviewAction', () => { isPaidAnimationRunning: undefined, isApprovedAnimationRunning: undefined, isSubmittingAnimationRunning: undefined, - violationsData: { - currentUserEmail: CURRENT_USER_EMAIL, - violations, - }, + violationsData: violations, }), ).toBe(CONST.REPORT.REPORT_PREVIEW_ACTIONS.VIEW); }); From 120bb9632a72273119b44f445dd98ac4f08029ca Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 23 Dec 2025 01:16:42 +0530 Subject: [PATCH 15/16] Fix the params --- src/libs/ReportPreviewActionUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportPreviewActionUtils.ts b/src/libs/ReportPreviewActionUtils.ts index 677d985aa673e..fdd16876cf9bf 100644 --- a/src/libs/ReportPreviewActionUtils.ts +++ b/src/libs/ReportPreviewActionUtils.ts @@ -207,7 +207,7 @@ function getReportPreviewAction({ return CONST.REPORT.REPORT_PREVIEW_ACTIONS.ADD_EXPENSE; } - if (canSubmit(report, isReportArchived, currentUserAccountID, violationsData?.currentUserEmail ?? '', violationsData?.violations, policy, transactions)) { + if (canSubmit(report, isReportArchived, currentUserAccountID, currentUserEmail, violationsData, policy, transactions)) { return CONST.REPORT.REPORT_PREVIEW_ACTIONS.SUBMIT; } if (canApprove(report, currentUserAccountID, policy, transactions)) { From 3a6c2d725fe2a67554822f2c7043e39f8fcfbeb2 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 30 Dec 2025 22:45:21 +0530 Subject: [PATCH 16/16] Add comment --- src/libs/Firebase/utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/Firebase/utils.ts b/src/libs/Firebase/utils.ts index f7bf4d89a2609..c472e3a87298d 100644 --- a/src/libs/Firebase/utils.ts +++ b/src/libs/Firebase/utils.ts @@ -59,6 +59,7 @@ Onyx.connectWithoutView({ }); let session: OnyxEntry; +// Firebase Utils are used for performance monitoring which does not affect the UI, hence using connectWithoutView Onyx.connectWithoutView({ key: ONYXKEYS.SESSION, callback: (value) => {