From a93d184b0f08ab51eb6e80e47283e0b2f4328004 Mon Sep 17 00:00:00 2001 From: jayeshmangwani Date: Wed, 24 Jun 2026 11:42:21 +0530 Subject: [PATCH 1/2] removed Onyx.connect from ReportNameUtils and passed value from parent --- src/libs/ReportNameUtils.ts | 17 ++++++--------- .../OnyxDerived/configs/reportAttributes.ts | 21 +++++++++++++++++-- tests/unit/OnyxDerivedTest.tsx | 7 +++++-- tests/unit/ReportNameUtilsTest.ts | 2 ++ tests/unit/ReportUtilsTest.ts | 1 + 5 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/libs/ReportNameUtils.ts b/src/libs/ReportNameUtils.ts index 9dc076a37c6a..3351c2309376 100644 --- a/src/libs/ReportNameUtils.ts +++ b/src/libs/ReportNameUtils.ts @@ -8,7 +8,6 @@ import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleCon import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type { - IntroSelected, PersonalDetails, PersonalDetailsList, Policy, @@ -185,6 +184,7 @@ type ComputeReportName = { // TODO: Make this required when https://github.com/Expensify/App/issues/66411 is done conciergeReportID?: string; reportAttributes?: ReportAttributesDerivedValue['reports']; + isTrackIntentUser: boolean | undefined; }; let allPersonalDetails: OnyxEntry; @@ -197,15 +197,6 @@ Onyx.connect({ }, }); -let introSelected: OnyxEntry; -// eslint-disable-next-line rulesdir/no-onyx-connect -- NextStepUtils is a pure utility called from action files that cannot use hooks -Onyx.connect({ - key: ONYXKEYS.NVP_INTRO_SELECTED, - callback: (value) => { - introSelected = value; - }, -}); - function generateArchivedReportName(reportName: string): string { return `${reportName} (${translateLocal('common.archived')}) `; } @@ -436,6 +427,7 @@ function computeReportNameBasedOnReportAction( parentReport: Report | undefined, personalDetailsList: OnyxEntry, reportAttributes: ReportAttributesDerivedValue['reports'] | undefined, + isTrackIntentUser: boolean | undefined, ): string | undefined { if (!parentReportAction) { return undefined; @@ -451,7 +443,7 @@ function computeReportNameBasedOnReportAction( } if ( shouldShowMarkAsDone({ - isTrackIntentUser: isTrackOnboardingChoice(introSelected?.choice), + isTrackIntentUser, policy: reportPolicy, report: parentReport, }) @@ -937,6 +929,7 @@ function computeReportName({ allPolicyTags, conciergeReportID, reportAttributes, + isTrackIntentUser, }: ComputeReportName): string { if (!report?.reportID) { return ''; @@ -955,6 +948,7 @@ function computeReportName({ parentReport, personalDetailsList, reportAttributes, + isTrackIntentUser, ); if (parentReportActionBasedName) { @@ -980,6 +974,7 @@ function computeReportName({ currentUserLogin, conciergeReportID, reportAttributes, + isTrackIntentUser, }); return getCreatedReportForUnapprovedTransactionsMessage(originalID, reportName, isOriginalReportDeleted(parentReportAction, originalReport), translateLocal); } diff --git a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts index afb7937405c8..e773e03514e7 100644 --- a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts +++ b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts @@ -1,5 +1,6 @@ import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import {getIsOffline} from '@libs/NetworkState'; +import isTrackOnboardingChoice from '@libs/OnboardingUtils'; import {getLinkedTransactionID} from '@libs/ReportActionsUtils'; import {computeReportName} from '@libs/ReportNameUtils'; import {generateIsEmptyReport, generateReportAttributes, hasVisibleReportFieldViolations, isArchivedReport, isPolicyAdmin, isPolicyExpenseChat, isValidReport} from '@libs/ReportUtils'; @@ -90,11 +91,25 @@ export default createOnyxDerivedValueConfig({ ONYXKEYS.COLLECTION.POLICY, ONYXKEYS.COLLECTION.POLICY_TAGS, ONYXKEYS.CONCIERGE_REPORT_ID, + ONYXKEYS.NVP_INTRO_SELECTED, ONYXKEYS.COLLECTION.REPORT_METADATA, ONYXKEYS.NETWORK, ], compute: ( - [reports, preferredLocale, transactionViolations, reportActions, reportNameValuePairs, transactions, personalDetails, session, policies, policyTags, conciergeReportID], + [ + reports, + preferredLocale, + transactionViolations, + reportActions, + reportNameValuePairs, + transactions, + personalDetails, + session, + policies, + policyTags, + conciergeReportID, + introSelected, + ], {currentValue, sourceValues}, ) => { // Read the in-memory offline state directly (NETWORK is a dependency so recompute still fires when it changes). @@ -118,7 +133,8 @@ export default createOnyxDerivedValueConfig({ let needsFullRecompute = (hasKeyTriggeredCompute(ONYXKEYS.NVP_PREFERRED_LOCALE, sourceValues) && preferredLocale !== currentValue?.locale) || displayNamesChanged || - hasKeyTriggeredCompute(ONYXKEYS.CONCIERGE_REPORT_ID, sourceValues); + hasKeyTriggeredCompute(ONYXKEYS.CONCIERGE_REPORT_ID, sourceValues) || + hasKeyTriggeredCompute(ONYXKEYS.NVP_INTRO_SELECTED, sourceValues); // if policies are loaded first time, we need to recompute all report attributes to get correct action badge in LHN, such as Approve because it depends on policy's type (see canApproveIOU function) const policyChangedReportKeys: string[] = []; @@ -356,6 +372,7 @@ export default createOnyxDerivedValueConfig({ allPolicyTags: policyTags, conciergeReportID: conciergeReportID ?? undefined, reportAttributes: currentValue?.reports, + isTrackIntentUser: isTrackOnboardingChoice(introSelected?.choice), }) : '', isEmpty: generateIsEmptyReport(report, isReportArchived), diff --git a/tests/unit/OnyxDerivedTest.tsx b/tests/unit/OnyxDerivedTest.tsx index 63311c1e21b8..06caed82cb3d 100644 --- a/tests/unit/OnyxDerivedTest.tsx +++ b/tests/unit/OnyxDerivedTest.tsx @@ -124,9 +124,12 @@ describe('OnyxDerived', () => { const transaction = createRandomTransaction(1); // When the report attributes are recomputed with both report and transaction updates - reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {}); + reportAttributes.compute( + [reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], + {}, + ); const reportAttributesComputedValue = reportAttributes.compute( - [reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], + [reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], { sourceValues: { [ONYXKEYS.COLLECTION.REPORT]: { diff --git a/tests/unit/ReportNameUtilsTest.ts b/tests/unit/ReportNameUtilsTest.ts index 0c52047d6c47..956a81859afd 100644 --- a/tests/unit/ReportNameUtilsTest.ts +++ b/tests/unit/ReportNameUtilsTest.ts @@ -45,6 +45,7 @@ describe('ReportNameUtils', () => { reportActions, currentUserAccountID: currentUserID, currentUserLogin, + isTrackIntentUser: false, }); const participantsPersonalDetails: PersonalDetailsList = [ { @@ -554,6 +555,7 @@ describe('ReportNameUtils', () => { currentUserAccountID, currentUserLogin: '', allPolicyTags: policyTagsCollection, + isTrackIntentUser: false, }); expect(name).toContain('Cost Center'); diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index e6d07bc36e45..fb40fb12c07a 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -307,6 +307,7 @@ const computeReportName = ( currentUserAccountID: currentUserID, currentUserLogin: currentUserEmail, conciergeReportID, + isTrackIntentUser: false, }); const participantsPersonalDetails: PersonalDetailsList = { '1': { From a0560f4b2b2747044b078685cbbaac2a6ea7720d Mon Sep 17 00:00:00 2001 From: jayeshmangwani Date: Wed, 24 Jun 2026 11:44:41 +0530 Subject: [PATCH 2/2] removed unused import --- src/libs/ReportNameUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/ReportNameUtils.ts b/src/libs/ReportNameUtils.ts index 34b80c3e58ea..47292f118391 100644 --- a/src/libs/ReportNameUtils.ts +++ b/src/libs/ReportNameUtils.ts @@ -27,7 +27,6 @@ import {formatPhoneNumber as formatPhoneNumberPhoneUtils} from './LocalePhoneNum import {translateLocal} from './Localize'; // eslint-disable-next-line import/no-cycle import {getForReportAction, getMovedReportID} from './ModifiedExpenseMessage'; -import isTrackOnboardingChoice from './OnboardingUtils'; import Parser from './Parser'; import {getDisplayNameOrDefault} from './PersonalDetailsUtils'; import {getCleanedTagName, isPolicyAdmin, isPolicyFieldListEmpty} from './PolicyUtils';