From 9f8d4fc79857253e45d6e4a7581e3185761cb6c1 Mon Sep 17 00:00:00 2001 From: Faizan Shoukat Abbasi Date: Thu, 18 Dec 2025 00:11:35 +0500 Subject: [PATCH 1/6] fix: use compute function for report name in convertIOUReportToExpenseReport Replace populateOptimisticReportFormula with compute function when converting IOU reports to expense reports. Pass transactions from UI via useOnyx hooks instead of using deprecated getReportTransactions. Changes: - Update convertIOUReportToExpenseReport to accept reportTransactions param - Update moveIOUReportToPolicy to pass reportTransactions - Update moveIOUReportToPolicyAndInviteSubmitter to pass reportTransactions - Update ReportChangeWorkspacePage to use useReportTransactions hook - Update SearchPage to filter and pass transactions - Update BaseKYCWall to use useReportTransactions hook --- src/components/KYCWall/BaseKYCWall.tsx | 7 ++++-- src/libs/actions/Report.ts | 31 +++++++++++++++++++------ src/pages/ReportChangeWorkspacePage.tsx | 7 ++++-- src/pages/Search/SearchPage.tsx | 10 +++++--- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/components/KYCWall/BaseKYCWall.tsx b/src/components/KYCWall/BaseKYCWall.tsx index ac4814c1a8f5..6ea8fcfdc943 100644 --- a/src/components/KYCWall/BaseKYCWall.tsx +++ b/src/components/KYCWall/BaseKYCWall.tsx @@ -8,6 +8,7 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails' import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import useParentReportAction from '@hooks/useParentReportAction'; +import useReportTransactions from '@hooks/useReportTransactions'; import {openPersonalBankAccountSetupView} from '@libs/actions/BankAccounts'; import {completePaymentOnboarding, savePreferredPaymentMethod} from '@libs/actions/IOU'; import {moveIOUReportToPolicy, moveIOUReportToPolicyAndInviteSubmitter} from '@libs/actions/Report'; @@ -66,6 +67,7 @@ function KYCWall({ const reportPreviewAction = useParentReportAction(iouReport); const personalDetails = usePersonalDetails(); const employeeEmail = personalDetails?.[iouReport?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID]?.login ?? ''; + const reportTransactions = useReportTransactions(iouReport?.reportID); const anchorRef = useRef(null); const transferBalanceButtonRef = useRef(null); @@ -129,7 +131,7 @@ function KYCWall({ if (iouReport && isIOUReport(iouReport)) { const adminPolicy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policy?.id}`]; if (adminPolicy) { - const inviteResult = moveIOUReportToPolicyAndInviteSubmitter(iouReport?.reportID, adminPolicy, formatPhoneNumber); + const inviteResult = moveIOUReportToPolicyAndInviteSubmitter(iouReport?.reportID, adminPolicy, formatPhoneNumber, reportTransactions); if (inviteResult?.policyExpenseChatReportID) { setNavigationActionToMicrotaskQueue(() => { Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(inviteResult.policyExpenseChatReportID)); @@ -139,7 +141,7 @@ function KYCWall({ Navigation.navigate(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute(adminPolicy.id)); }); } else { - const moveResult = moveIOUReportToPolicy(iouReport?.reportID, adminPolicy, true); + const moveResult = moveIOUReportToPolicy(iouReport?.reportID, adminPolicy, true, reportTransactions); savePreferredPaymentMethod(iouReport.policyID, adminPolicy.id, CONST.LAST_PAYMENT_METHOD.IOU, lastPaymentMethod?.[adminPolicy.id]); if (moveResult?.policyExpenseChatReportID && !moveResult.useTemporaryOptimisticExpenseChatReportID) { @@ -186,6 +188,7 @@ function KYCWall({ reportPreviewAction, currentUserEmail, employeeEmail, + reportTransactions, ], ); diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 0be98707ea04..0b808173a92e 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -164,7 +164,6 @@ import { isSelfDM, isUnread, isValidReportIDFromPath, - populateOptimisticReportFormula, prepareOnboardingOnyxData, } from '@libs/ReportUtils'; import {getCurrentSearchQueryJSON} from '@libs/SearchQueryUtils'; @@ -5268,11 +5267,13 @@ function deleteAppReport(reportID: string | undefined, currentUserEmailParam: st * @param reportID - The ID of the IOU report to move * @param policy - The policy to move the report to * @param isFromSettlementButton - Whether the action is from report preview + * @param reportTransactions - The transactions for this report (from useOnyx) */ function moveIOUReportToPolicy( reportID: string, policy: Policy, isFromSettlementButton?: boolean, + reportTransactions: Transaction[] = [], ): {policyExpenseChatReportID?: string; useTemporaryOptimisticExpenseChatReportID: boolean} | undefined { const iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; @@ -5299,6 +5300,7 @@ function moveIOUReportToPolicy( policy, policyID, optimisticExpenseChatReportID, + reportTransactions, ); const parameters: MoveIOUReportToExistingPolicyParams = { @@ -5316,11 +5318,15 @@ function moveIOUReportToPolicy( /** * Moves an IOU report to a policy by converting it to an expense report * @param reportID - The ID of the IOU report to move + * @param policy - The policy to move the report to + * @param formatPhoneNumber - Function to format phone numbers + * @param reportTransactions - The transactions for this report (from useOnyx) */ function moveIOUReportToPolicyAndInviteSubmitter( reportID: string, policy: Policy, formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], + reportTransactions: Transaction[] = [], ): {policyExpenseChatReportID?: string} | undefined { const iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; @@ -5425,7 +5431,7 @@ function moveIOUReportToPolicyAndInviteSubmitter( failureData: convertedFailureData, movedExpenseReportAction, movedReportAction, - } = convertIOUReportToExpenseReport(iouReport, policy, policyID, optimisticPolicyExpenseChatReportID); + } = convertIOUReportToExpenseReport(iouReport, policy, policyID, optimisticPolicyExpenseChatReportID, reportTransactions); optimisticData.push(...convertedOptimisticData); successData.push(...convertedSuccessData); @@ -5444,7 +5450,7 @@ function moveIOUReportToPolicyAndInviteSubmitter( return {policyExpenseChatReportID: optimisticPolicyExpenseChatReportID}; } -function convertIOUReportToExpenseReport(iouReport: Report, policy: Policy, policyID: string, optimisticPolicyExpenseChatReportID: string) { +function convertIOUReportToExpenseReport(iouReport: Report, policy: Policy, policyID: string, optimisticPolicyExpenseChatReportID: string, reportTransactions: Transaction[] = []) { const optimisticData: OnyxUpdate[] = []; const successData: OnyxUpdate[] = []; const failureData: OnyxUpdate[] = []; @@ -5468,7 +5474,21 @@ function convertIOUReportToExpenseReport(iouReport: Report, policy: Policy, poli const titleReportField = getTitleReportField(getReportFieldsByPolicyID(policyID) ?? {}); if (!!titleReportField && isPaidGroupPolicy(policy)) { - expenseReport.reportName = populateOptimisticReportFormula(titleReportField.defaultValue, expenseReport, policy); + // Convert transactions array to Record for FormulaContext + const transactionsRecord: Record = {}; + for (const transaction of reportTransactions) { + if (transaction?.transactionID) { + transactionsRecord[transaction.transactionID] = transaction; + } + } + // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires + const Formula = require('@libs/Formula') as {compute: (formula?: string, context?: {report: Report; policy: Policy; allTransactions?: Record}) => string}; + const computedName = Formula.compute(titleReportField.defaultValue, { + report: expenseReport, + policy, + allTransactions: transactionsRecord, + }); + expenseReport.reportName = computedName || expenseReport.reportName; } const reportID = iouReport.reportID; @@ -5484,9 +5504,6 @@ function convertIOUReportToExpenseReport(iouReport: Report, policy: Policy, poli value: iouReport, }); - // The expense report transactions need to have the amount reversed to negative values - const reportTransactions = getReportTransactions(reportID); - // For performance reasons, we are going to compose a merge collection data for transactions const transactionsOptimisticData: Record = {}; const transactionFailureData: Record = {}; diff --git a/src/pages/ReportChangeWorkspacePage.tsx b/src/pages/ReportChangeWorkspacePage.tsx index 2626f6ab67ff..f63af65b2804 100644 --- a/src/pages/ReportChangeWorkspacePage.tsx +++ b/src/pages/ReportChangeWorkspacePage.tsx @@ -13,6 +13,7 @@ import useNetwork from '@hooks/useNetwork'; import useOnyx from '@hooks/useOnyx'; import usePermissions from '@hooks/usePermissions'; import useReportIsArchived from '@hooks/useReportIsArchived'; +import useReportTransactions from '@hooks/useReportTransactions'; import useThemeStyles from '@hooks/useThemeStyles'; import useWorkspaceList from '@hooks/useWorkspaceList'; import {changeReportPolicy, changeReportPolicyAndInviteSubmitter, moveIOUReportToPolicy, moveIOUReportToPolicyAndInviteSubmitter} from '@libs/actions/Report'; @@ -48,6 +49,7 @@ function ReportChangeWorkspacePage({report, route}: ReportChangeWorkspacePagePro const styles = useThemeStyles(); const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState(''); const {translate, formatPhoneNumber, localeCompare} = useLocalize(); + const reportTransactions = useReportTransactions(reportID); const [policies, fetchStatus] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: false}); const [reportNextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${reportID}`, {canBeMissing: true}); @@ -75,9 +77,9 @@ function ReportChangeWorkspacePage({report, route}: ReportChangeWorkspacePagePro const {backTo} = route.params; Navigation.goBack(backTo); if (isIOUReport(reportID)) { - const invite = moveIOUReportToPolicyAndInviteSubmitter(reportID, policy, formatPhoneNumber); + const invite = moveIOUReportToPolicyAndInviteSubmitter(reportID, policy, formatPhoneNumber, reportTransactions); if (!invite?.policyExpenseChatReportID) { - moveIOUReportToPolicy(reportID, policy); + moveIOUReportToPolicy(reportID, policy, false, reportTransactions); } // This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850 // eslint-disable-next-line @typescript-eslint/no-deprecated @@ -115,6 +117,7 @@ function ReportChangeWorkspacePage({report, route}: ReportChangeWorkspacePagePro reportID, report, formatPhoneNumber, + reportTransactions, isReportLastVisibleArchived, session?.accountID, session?.email, diff --git a/src/pages/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx index 3036b9b7cf31..c4fa49b466b0 100644 --- a/src/pages/Search/SearchPage.tsx +++ b/src/pages/Search/SearchPage.tsx @@ -286,9 +286,13 @@ function SearchPage({route}: SearchPageProps) { ); return; } - const invite = moveIOUReportToPolicyAndInviteSubmitter(itemReportID, adminPolicy, formatPhoneNumber); + // Get transactions for this report + const reportTransactions = Object.values(allTransactions ?? {}).filter( + (transaction): transaction is NonNullable => !!transaction && transaction.reportID === itemReportID, + ); + const invite = moveIOUReportToPolicyAndInviteSubmitter(itemReportID, adminPolicy, formatPhoneNumber, reportTransactions); if (!invite?.policyExpenseChatReportID) { - moveIOUReportToPolicy(itemReportID, adminPolicy); + moveIOUReportToPolicy(itemReportID, adminPolicy, false, reportTransactions); } } } @@ -331,7 +335,7 @@ function SearchPage({route}: SearchPageProps) { clearSelectedTransactions(); }); }, - [clearSelectedTransactions, hash, isOffline, lastPaymentMethods, selectedReports, selectedTransactions, policies, formatPhoneNumber, policyIDsWithVBBA], + [clearSelectedTransactions, hash, isOffline, lastPaymentMethods, selectedReports, selectedTransactions, policies, formatPhoneNumber, policyIDsWithVBBA, allTransactions], ); // Check if all selected transactions are from the submitter From b7fa5fb4bfaa73e484c3bd244b661800265edeb3 Mon Sep 17 00:00:00 2001 From: Faizan Shoukat Abbasi Date: Thu, 15 Jan 2026 01:38:09 +0500 Subject: [PATCH 2/6] removed extra comments --- src/libs/actions/Report.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 4cbd0b704d5d..3436bb094353 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -5331,10 +5331,6 @@ function deleteAppReport( /** * Moves an IOU report to a policy by converting it to an expense report - * @param reportID - The ID of the IOU report to move - * @param policy - The policy to move the report to - * @param isFromSettlementButton - Whether the action is from report preview - * @param reportTransactions - The transactions for this report (from useOnyx) */ function moveIOUReportToPolicy( reportID: string, @@ -5383,11 +5379,7 @@ function moveIOUReportToPolicy( } /** - * Moves an IOU report to a policy by converting it to an expense report - * @param reportID - The ID of the IOU report to move - * @param policy - The policy to move the report to - * @param formatPhoneNumber - Function to format phone numbers - * @param reportTransactions - The transactions for this report (from useOnyx) + * Moves an IOU report to a policy by converting it to an expense report and invites the submitter */ function moveIOUReportToPolicyAndInviteSubmitter( reportID: string, From d1117f7f2d9a9fb5ba3b8248f415d603d63c6408 Mon Sep 17 00:00:00 2001 From: Faizan Shoukat Abbasi Date: Fri, 16 Jan 2026 03:16:56 +0500 Subject: [PATCH 3/6] Added beta check --- src/libs/actions/Report.ts | 42 ++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 3436bb094353..64ae501346f3 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -86,6 +86,7 @@ import {rand64} from '@libs/NumberUtils'; import capturePageHTML from '@libs/PageHTMLCapture'; import Parser from '@libs/Parser'; import {getParsedMessageWithShortMentions} from '@libs/ParsingUtils'; +import Permissions from '@libs/Permissions'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as PhoneNumber from '@libs/PhoneNumber'; import { @@ -182,6 +183,7 @@ import ROUTES from '@src/ROUTES'; import INPUT_IDS from '@src/types/form/NewRoomForm'; import type { BankAccountList, + Beta, IntroSelected, InvitedEmailsToAccountIDs, NewGroupChatDraft, @@ -360,6 +362,12 @@ Onyx.connect({ callback: (value) => (allReportDraftComments = value), }); +let allBetas: OnyxEntry; +Onyx.connect({ + key: ONYXKEYS.BETAS, + callback: (value) => (allBetas = value), +}); + let environment: EnvironmentType; getEnvironment().then((env) => { environment = env; @@ -5531,23 +5539,27 @@ function convertIOUReportToExpenseReport(iouReport: Report, policy: Policy, poli expenseReport.managerID = nextApproverAccountID; } - const titleReportField = getTitleReportField(getReportFieldsByPolicyID(policyID) ?? {}); - if (!!titleReportField && isPaidGroupPolicy(policy)) { - // Convert transactions array to Record for FormulaContext - const transactionsRecord: Record = {}; - for (const transaction of reportTransactions) { - if (transaction?.transactionID) { - transactionsRecord[transaction.transactionID] = transaction; + // Only compute optimistic report name if the user is on the CUSTOM_REPORT_NAMES beta + if (Permissions.isBetaEnabled(CONST.BETAS.CUSTOM_REPORT_NAMES, allBetas)) { + const titleReportField = getTitleReportField(getReportFieldsByPolicyID(policyID) ?? {}); + if (!!titleReportField && isPaidGroupPolicy(policy)) { + // Convert transactions array to Record for FormulaContext + const transactionsRecord: Record = {}; + for (const transaction of reportTransactions) { + if (transaction?.transactionID) { + transactionsRecord[transaction.transactionID] = transaction; + } } + + // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires + const Formula = require('@libs/Formula') as {compute: (formula?: string, context?: {report: Report; policy: Policy; allTransactions?: Record}) => string}; + const computedName = Formula.compute(titleReportField.defaultValue, { + report: expenseReport, + policy, + allTransactions: transactionsRecord, + }); + expenseReport.reportName = computedName ?? expenseReport.reportName; } - // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires - const Formula = require('@libs/Formula') as {compute: (formula?: string, context?: {report: Report; policy: Policy; allTransactions?: Record}) => string}; - const computedName = Formula.compute(titleReportField.defaultValue, { - report: expenseReport, - policy, - allTransactions: transactionsRecord, - }); - expenseReport.reportName = computedName || expenseReport.reportName; } const reportID = iouReport.reportID; From 478911a7ac4d35072b97b4ed82d6d281c7622b3a Mon Sep 17 00:00:00 2001 From: Faizan Shoukat Abbasi Date: Fri, 16 Jan 2026 20:45:53 +0500 Subject: [PATCH 4/6] avoid the deprecated Onyx.connect and instead pass a flag from UI components using usePermissions --- src/components/KYCWall/BaseKYCWall.tsx | 7 +++++-- src/libs/actions/Report.ts | 24 +++++++++++++----------- src/pages/ReportChangeWorkspacePage.tsx | 6 ++++-- src/pages/Search/SearchPage.tsx | 6 ++++-- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/components/KYCWall/BaseKYCWall.tsx b/src/components/KYCWall/BaseKYCWall.tsx index 69ec2f3aaaba..ea486517c341 100644 --- a/src/components/KYCWall/BaseKYCWall.tsx +++ b/src/components/KYCWall/BaseKYCWall.tsx @@ -7,6 +7,7 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails' import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import useParentReportAction from '@hooks/useParentReportAction'; +import usePermissions from '@hooks/usePermissions'; import useReportTransactions from '@hooks/useReportTransactions'; import {openPersonalBankAccountSetupView} from '@libs/actions/BankAccounts'; import {completePaymentOnboarding, savePreferredPaymentMethod} from '@libs/actions/IOU'; @@ -72,6 +73,8 @@ function KYCWall({ const personalDetails = usePersonalDetails(); const employeeEmail = personalDetails?.[iouReport?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID]?.login ?? ''; const reportTransactions = useReportTransactions(iouReport?.reportID); + const {isBetaEnabled} = usePermissions(); + const isCustomReportNamesBetaEnabled = isBetaEnabled(CONST.BETAS.CUSTOM_REPORT_NAMES); const anchorRef = useRef(null); const transferBalanceButtonRef = useRef(null); @@ -137,7 +140,7 @@ function KYCWall({ if (iouReport && isIOUReport(iouReport)) { const adminPolicy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policy?.id}`]; if (adminPolicy) { - const inviteResult = moveIOUReportToPolicyAndInviteSubmitter(iouReport?.reportID, adminPolicy, formatPhoneNumber, reportTransactions); + const inviteResult = moveIOUReportToPolicyAndInviteSubmitter(iouReport?.reportID, adminPolicy, formatPhoneNumber, reportTransactions, isCustomReportNamesBetaEnabled); if (inviteResult?.policyExpenseChatReportID) { setNavigationActionToMicrotaskQueue(() => { Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(inviteResult.policyExpenseChatReportID)); @@ -147,7 +150,7 @@ function KYCWall({ Navigation.navigate(ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN.getRoute(adminPolicy.id)); }); } else { - const moveResult = moveIOUReportToPolicy(iouReport?.reportID, adminPolicy, true, reportTransactions); + const moveResult = moveIOUReportToPolicy(iouReport?.reportID, adminPolicy, true, reportTransactions, isCustomReportNamesBetaEnabled); savePreferredPaymentMethod(iouReport.policyID, adminPolicy.id, CONST.LAST_PAYMENT_METHOD.IOU, lastPaymentMethod?.[adminPolicy.id]); if (moveResult?.policyExpenseChatReportID && !moveResult.useTemporaryOptimisticExpenseChatReportID) { diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 64ae501346f3..215eb5418b4e 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -86,7 +86,6 @@ import {rand64} from '@libs/NumberUtils'; import capturePageHTML from '@libs/PageHTMLCapture'; import Parser from '@libs/Parser'; import {getParsedMessageWithShortMentions} from '@libs/ParsingUtils'; -import Permissions from '@libs/Permissions'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import * as PhoneNumber from '@libs/PhoneNumber'; import { @@ -183,7 +182,6 @@ import ROUTES from '@src/ROUTES'; import INPUT_IDS from '@src/types/form/NewRoomForm'; import type { BankAccountList, - Beta, IntroSelected, InvitedEmailsToAccountIDs, NewGroupChatDraft, @@ -362,12 +360,6 @@ Onyx.connect({ callback: (value) => (allReportDraftComments = value), }); -let allBetas: OnyxEntry; -Onyx.connect({ - key: ONYXKEYS.BETAS, - callback: (value) => (allBetas = value), -}); - let environment: EnvironmentType; getEnvironment().then((env) => { environment = env; @@ -5345,6 +5337,7 @@ function moveIOUReportToPolicy( policy: Policy, isFromSettlementButton?: boolean, reportTransactions: Transaction[] = [], + isCustomReportNamesBetaEnabled?: boolean, ): {policyExpenseChatReportID?: string; useTemporaryOptimisticExpenseChatReportID: boolean} | undefined { const iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; @@ -5372,6 +5365,7 @@ function moveIOUReportToPolicy( policyID, optimisticExpenseChatReportID, reportTransactions, + isCustomReportNamesBetaEnabled, ); const parameters: MoveIOUReportToExistingPolicyParams = { @@ -5394,6 +5388,7 @@ function moveIOUReportToPolicyAndInviteSubmitter( policy: Policy, formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], reportTransactions: Transaction[] = [], + isCustomReportNamesBetaEnabled?: boolean, ): {policyExpenseChatReportID?: string} | undefined { const iouReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; @@ -5498,7 +5493,7 @@ function moveIOUReportToPolicyAndInviteSubmitter( failureData: convertedFailureData, movedExpenseReportAction, movedReportAction, - } = convertIOUReportToExpenseReport(iouReport, policy, policyID, optimisticPolicyExpenseChatReportID, reportTransactions); + } = convertIOUReportToExpenseReport(iouReport, policy, policyID, optimisticPolicyExpenseChatReportID, reportTransactions, isCustomReportNamesBetaEnabled); optimisticData.push(...convertedOptimisticData); successData.push(...convertedSuccessData); @@ -5517,7 +5512,14 @@ function moveIOUReportToPolicyAndInviteSubmitter( return {policyExpenseChatReportID: optimisticPolicyExpenseChatReportID}; } -function convertIOUReportToExpenseReport(iouReport: Report, policy: Policy, policyID: string, optimisticPolicyExpenseChatReportID: string, reportTransactions: Transaction[] = []) { +function convertIOUReportToExpenseReport( + iouReport: Report, + policy: Policy, + policyID: string, + optimisticPolicyExpenseChatReportID: string, + reportTransactions: Transaction[] = [], + isCustomReportNamesBetaEnabled?: boolean, +) { const optimisticData: Array> = []; const successData: Array> = []; const failureData: Array> = []; @@ -5540,7 +5542,7 @@ function convertIOUReportToExpenseReport(iouReport: Report, policy: Policy, poli } // Only compute optimistic report name if the user is on the CUSTOM_REPORT_NAMES beta - if (Permissions.isBetaEnabled(CONST.BETAS.CUSTOM_REPORT_NAMES, allBetas)) { + if (isCustomReportNamesBetaEnabled) { const titleReportField = getTitleReportField(getReportFieldsByPolicyID(policyID) ?? {}); if (!!titleReportField && isPaidGroupPolicy(policy)) { // Convert transactions array to Record for FormulaContext diff --git a/src/pages/ReportChangeWorkspacePage.tsx b/src/pages/ReportChangeWorkspacePage.tsx index 7d368eda112e..e34191b5acc1 100644 --- a/src/pages/ReportChangeWorkspacePage.tsx +++ b/src/pages/ReportChangeWorkspacePage.tsx @@ -66,6 +66,7 @@ function ReportChangeWorkspacePage({report, route}: ReportChangeWorkspacePagePro const shouldShowLoadingIndicator = isLoadingApp && !isOffline; const {isBetaEnabled} = usePermissions(); const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT); + const isCustomReportNamesBetaEnabled = isBetaEnabled(CONST.BETAS.CUSTOM_REPORT_NAMES); const session = useSession(); const hasViolations = hasViolationsReportUtils(report?.reportID, transactionViolations, session?.accountID ?? CONST.DEFAULT_NUMBER_ID, session?.email ?? ''); @@ -78,9 +79,9 @@ function ReportChangeWorkspacePage({report, route}: ReportChangeWorkspacePagePro const {backTo} = route.params; Navigation.goBack(backTo); if (isIOUReport(reportID)) { - const invite = moveIOUReportToPolicyAndInviteSubmitter(reportID, policy, formatPhoneNumber, reportTransactions); + const invite = moveIOUReportToPolicyAndInviteSubmitter(reportID, policy, formatPhoneNumber, reportTransactions, isCustomReportNamesBetaEnabled); if (!invite?.policyExpenseChatReportID) { - moveIOUReportToPolicy(reportID, policy, false, reportTransactions); + moveIOUReportToPolicy(reportID, policy, false, reportTransactions, isCustomReportNamesBetaEnabled); } // This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850 // eslint-disable-next-line @typescript-eslint/no-deprecated @@ -124,6 +125,7 @@ function ReportChangeWorkspacePage({report, route}: ReportChangeWorkspacePagePro session?.email, hasViolations, isASAPSubmitBetaEnabled, + isCustomReportNamesBetaEnabled, reportNextStep, isChangePolicyTrainingModalDismissed, ], diff --git a/src/pages/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx index cd3aa3e5e607..b9fb1414eddf 100644 --- a/src/pages/Search/SearchPage.tsx +++ b/src/pages/Search/SearchPage.tsx @@ -135,6 +135,7 @@ function SearchPage({route}: SearchPageProps) { const {showConfirmModal} = useConfirmModal(); const {isBetaEnabled} = usePermissions(); const isDEWBetaEnabled = isBetaEnabled(CONST.BETAS.NEW_DOT_DEW); + const isCustomReportNamesBetaEnabled = isBetaEnabled(CONST.BETAS.CUSTOM_REPORT_NAMES); const [isHoldEducationalModalVisible, setIsHoldEducationalModalVisible] = useState(false); const [rejectModalAction, setRejectModalAction] = useState => !!transaction && transaction.reportID === itemReportID, ); - const invite = moveIOUReportToPolicyAndInviteSubmitter(itemReportID, adminPolicy, formatPhoneNumber, reportTransactions); + const invite = moveIOUReportToPolicyAndInviteSubmitter(itemReportID, adminPolicy, formatPhoneNumber, reportTransactions, isCustomReportNamesBetaEnabled); if (!invite?.policyExpenseChatReportID) { - moveIOUReportToPolicy(itemReportID, adminPolicy, false, reportTransactions); + moveIOUReportToPolicy(itemReportID, adminPolicy, false, reportTransactions, isCustomReportNamesBetaEnabled); } } } @@ -576,6 +577,7 @@ function SearchPage({route}: SearchPageProps) { showDelegateNoAccessModal, personalPolicyID, allTransactions, + isCustomReportNamesBetaEnabled, ], ); From c72248da731b7d0593560a9b382d432969b236ec Mon Sep 17 00:00:00 2001 From: Faizan Shoukat Abbasi Date: Thu, 22 Jan 2026 02:20:01 +0500 Subject: [PATCH 5/6] fixed lint issues --- src/components/KYCWall/BaseKYCWall.tsx | 4 ++-- src/components/KYCWall/types.ts | 2 +- src/pages/ReportChangeWorkspacePage.tsx | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/KYCWall/BaseKYCWall.tsx b/src/components/KYCWall/BaseKYCWall.tsx index ea486517c341..4701c431af66 100644 --- a/src/components/KYCWall/BaseKYCWall.tsx +++ b/src/components/KYCWall/BaseKYCWall.tsx @@ -28,7 +28,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {BankAccountList, Policy} from '@src/types/onyx'; import {getEmptyObject} from '@src/types/utils/EmptyObject'; -import viewRef from '@src/types/utils/viewRef'; import type {AnchorPosition, ContinueActionParams, DomRect, KYCWallProps, PaymentMethod} from './types'; // This sets the Horizontal anchor position offset for POPOVER MENU. @@ -216,6 +215,7 @@ function KYCWall({ currentUserEmail, employeeEmail, reportTransactions, + isCustomReportNamesBetaEnabled, ], ); @@ -369,7 +369,7 @@ function KYCWall({ }} shouldShowPersonalBankAccountOption={shouldShowPersonalBankAccountOption} /> - {children(continueAction, viewRef(anchorRef))} + {children(continueAction, anchorRef)} ); } diff --git a/src/components/KYCWall/types.ts b/src/components/KYCWall/types.ts index 80f6be6afbc9..8f3813f08a87 100644 --- a/src/components/KYCWall/types.ts +++ b/src/components/KYCWall/types.ts @@ -70,7 +70,7 @@ type KYCWallProps = { onSuccessfulKYC: (iouPaymentType?: PaymentMethodType, currentSource?: Source) => void; /** Children to build the KYC */ - children: (continueAction: (params?: ContinueActionParams) => void, anchorRef: RefObject) => void; + children: (continueAction: (params?: ContinueActionParams) => void, anchorRef: RefObject) => void; /** The policy used for payment */ policy?: Policy; diff --git a/src/pages/ReportChangeWorkspacePage.tsx b/src/pages/ReportChangeWorkspacePage.tsx index 0c0381c0aa5f..3e2c148f568c 100644 --- a/src/pages/ReportChangeWorkspacePage.tsx +++ b/src/pages/ReportChangeWorkspacePage.tsx @@ -60,9 +60,10 @@ function ReportChangeWorkspacePage({report, route}: ReportChangeWorkspacePagePro const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: false}); const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {canBeMissing: true}); const isReportLastVisibleArchived = useReportIsArchived(report?.parentReportID); + const reportOwnerAccountID = report?.ownerAccountID; const submitterEmailSelector = useCallback( - (personalDetailsList: OnyxEntry) => personalDetailsList?.[report?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID]?.login, - [report?.ownerAccountID], + (personalDetailsList: OnyxEntry) => personalDetailsList?.[reportOwnerAccountID ?? CONST.DEFAULT_NUMBER_ID]?.login, + [reportOwnerAccountID], ); const [submitterEmail] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {canBeMissing: false, selector: submitterEmailSelector}, [submitterEmailSelector]); const shouldShowLoadingIndicator = isLoadingApp && !isOffline; From 1e0af7c1b9acc3dd6eb21d5516301d7a87459050 Mon Sep 17 00:00:00 2001 From: Faizan Shoukat Abbasi Date: Thu, 22 Jan 2026 03:01:14 +0500 Subject: [PATCH 6/6] Fixed lint issues --- src/components/KYCWall/BaseKYCWall.tsx | 3 ++- src/components/KYCWall/types.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/KYCWall/BaseKYCWall.tsx b/src/components/KYCWall/BaseKYCWall.tsx index 4701c431af66..fdb139f30b43 100644 --- a/src/components/KYCWall/BaseKYCWall.tsx +++ b/src/components/KYCWall/BaseKYCWall.tsx @@ -28,6 +28,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {BankAccountList, Policy} from '@src/types/onyx'; import {getEmptyObject} from '@src/types/utils/EmptyObject'; +import viewRef from '@src/types/utils/viewRef'; import type {AnchorPosition, ContinueActionParams, DomRect, KYCWallProps, PaymentMethod} from './types'; // This sets the Horizontal anchor position offset for POPOVER MENU. @@ -369,7 +370,7 @@ function KYCWall({ }} shouldShowPersonalBankAccountOption={shouldShowPersonalBankAccountOption} /> - {children(continueAction, anchorRef)} + {children(continueAction, viewRef(anchorRef))} ); } diff --git a/src/components/KYCWall/types.ts b/src/components/KYCWall/types.ts index 8f3813f08a87..80f6be6afbc9 100644 --- a/src/components/KYCWall/types.ts +++ b/src/components/KYCWall/types.ts @@ -70,7 +70,7 @@ type KYCWallProps = { onSuccessfulKYC: (iouPaymentType?: PaymentMethodType, currentSource?: Source) => void; /** Children to build the KYC */ - children: (continueAction: (params?: ContinueActionParams) => void, anchorRef: RefObject) => void; + children: (continueAction: (params?: ContinueActionParams) => void, anchorRef: RefObject) => void; /** The policy used for payment */ policy?: Policy;