From 19d7563b259bb3206ba4b0bdad0bc7830147a422 Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Wed, 31 Dec 2025 00:50:01 +0530
Subject: [PATCH 1/7] Onyx.connect() removal for ONYXKEYS.SESSION in
ReportNameUtils
---
package.json | 2 +-
src/components/TransactionItemRow/index.tsx | 5 +-
src/libs/OptionsListUtils/index.ts | 8 +-
src/libs/ReportNameUtils.ts | 25 +++--
src/libs/ReportUtils.ts | 5 +-
.../OnyxDerived/configs/reportAttributes.ts | 5 +-
src/pages/Search/AdvancedSearchFilters.tsx | 10 +-
src/pages/iou/SplitExpenseEditPage.tsx | 3 +-
tests/unit/ReportNameUtilsTest.ts | 100 +++++++++++++++---
tests/unit/ReportUtilsTest.ts | 22 ++--
10 files changed, 141 insertions(+), 44 deletions(-)
diff --git a/package.json b/package.json
index ebb9006e2495..aa44b724f2df 100644
--- a/package.json
+++ b/package.json
@@ -47,7 +47,7 @@
"test:debug": "TZ=utc NODE_OPTIONS='--inspect-brk --experimental-vm-modules' jest --runInBand",
"perf-test": "NODE_OPTIONS=--experimental-vm-modules npx reassure",
"typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc",
- "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=111 --cache --cache-location=node_modules/.cache/eslint --cache-strategy content --concurrency=auto",
+ "lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=110 --cache --cache-location=node_modules/.cache/eslint --cache-strategy content --concurrency=auto",
"lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 ./scripts/lintChanged.sh",
"check-lazy-loading": "ts-node scripts/checkLazyLoading.ts",
"lint-watch": "npx eslint-watch --watch --changed",
diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx
index 629b8c92d726..4305d4ac75db 100644
--- a/src/components/TransactionItemRow/index.tsx
+++ b/src/components/TransactionItemRow/index.tsx
@@ -18,6 +18,7 @@ import WorkspaceCell from '@components/SelectionListWithSections/Search/Workspac
import Text from '@components/Text';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
+import useOnyx from '@hooks/useOnyx';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
@@ -43,6 +44,7 @@ import {
} from '@libs/TransactionUtils';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
+import ONYXKEYS from '@src/ONYXKEYS';
import type {PersonalDetails, Policy, Report, TransactionViolation} from '@src/types/onyx';
import type {SearchTransactionAction} from '@src/types/onyx/SearchResults';
import CategoryCell from './DataCells/CategoryCell';
@@ -184,6 +186,7 @@ function TransactionItemRow({
const StyleUtils = useStyleUtils();
const theme = useTheme();
const {isLargeScreenWidth} = useResponsiveLayout();
+ const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true});
const hasCategoryOrTag = !isCategoryMissing(transactionItem?.category) || !!transactionItem.tag;
const createdAt = getTransactionCreated(transactionItem);
const expensicons = useMemoizedLazyExpensifyIcons(['ArrowRight']);
@@ -527,7 +530,7 @@ function TransactionItemRow({
[CONST.SEARCH.TABLE_COLUMNS.TITLE]: (
diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts
index ad5d5a36e8c9..95c05abb05a4 100644
--- a/src/libs/OptionsListUtils/index.ts
+++ b/src/libs/OptionsListUtils/index.ts
@@ -654,7 +654,7 @@ function getLastMessageTextForReport({
: undefined;
// For workspace chats, use the report title
if (reportUtilsIsPolicyExpenseChat(report) && !isEmptyObject(iouReport)) {
- const reportName = computeReportName(iouReport);
+ const reportName = computeReportName(iouReport, undefined, undefined, undefined, undefined, undefined, undefined, currentUserAccountID);
lastMessageTextFromReport = formatReportLastMessageText(reportName);
} else {
const reportPreviewMessage = getReportPreviewMessage(
@@ -914,7 +914,7 @@ function createOption(
: getAlternateText(result, {showChatPreviewLine, forcePolicyNamePreview}, !!result.private_isArchived, lastActorDetails);
const personalDetailsForCompute: PersonalDetailsList | undefined = personalDetails ?? undefined;
- const computedReportName = computeReportName(report, allReports, allPolicies, undefined, allReportNameValuePairs, personalDetailsForCompute, allReportActions);
+ const computedReportName = computeReportName(report, allReports, allPolicies, undefined, allReportNameValuePairs, personalDetailsForCompute, allReportActions, currentUserAccountID);
reportName = showPersonalDetails
? getDisplayNameForParticipant({accountID: accountIDs.at(0), formatPhoneNumber: formatPhoneNumberPhoneUtils}) || formatPhoneNumberPhoneUtils(personalDetail?.login ?? '')
: computedReportName;
@@ -976,7 +976,7 @@ function getReportOption(participant: Participant, reportAttributesDerived?: Rep
// eslint-disable-next-line @typescript-eslint/no-deprecated
option.alternateText = translateLocal('reportActionsView.yourSpace');
} else if (option.isInvoiceRoom) {
- option.text = computeReportName(report, undefined, undefined, undefined, allReportNameValuePairs, allPersonalDetails, undefined);
+ option.text = computeReportName(report, undefined, undefined, undefined, allReportNameValuePairs, allPersonalDetails, undefined, currentUserAccountID);
// eslint-disable-next-line @typescript-eslint/no-deprecated
option.alternateText = translateLocal('workspace.common.invoices');
} else {
@@ -1025,7 +1025,7 @@ function getReportDisplayOption(report: OnyxEntry, unknownUserDetails: O
// eslint-disable-next-line @typescript-eslint/no-deprecated
option.alternateText = translateLocal('reportActionsView.yourSpace');
} else if (option.isInvoiceRoom) {
- option.text = computeReportName(report, undefined, undefined, undefined, allReportNameValuePairs, allPersonalDetails, undefined);
+ option.text = computeReportName(report, undefined, undefined, undefined, allReportNameValuePairs, allPersonalDetails, undefined, currentUserAccountID);
// eslint-disable-next-line @typescript-eslint/no-deprecated
option.alternateText = translateLocal('workspace.common.invoices');
} else if (unknownUserDetails) {
diff --git a/src/libs/ReportNameUtils.ts b/src/libs/ReportNameUtils.ts
index 373539083db6..8582f01ba095 100644
--- a/src/libs/ReportNameUtils.ts
+++ b/src/libs/ReportNameUtils.ts
@@ -114,16 +114,8 @@ import {
isUserCreatedPolicyRoom,
} from './ReportUtils';
-let currentUserAccountID: number | undefined;
let allPersonalDetails: OnyxEntry;
-Onyx.connect({
- key: ONYXKEYS.SESSION,
- callback: (value) => {
- currentUserAccountID = value?.accountID;
- },
-});
-
Onyx.connect({
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
@@ -141,7 +133,15 @@ function generateArchivedReportName(reportName: string): string {
* This function is useful in contexts such as 1:1 direct messages (DMs) or other group chats.
* It limits to a maximum of 5 participants for the title and uses short names unless there is only one participant.
*/
-const buildReportNameFromParticipantNames = ({report, personalDetailsList: personalDetailsData}: {report: OnyxEntry; personalDetailsList?: Partial}) =>
+const buildReportNameFromParticipantNames = ({
+ report,
+ personalDetailsList: personalDetailsData,
+ currentUserAccountID,
+}: {
+ report: OnyxEntry;
+ personalDetailsList?: Partial;
+ currentUserAccountID?: number;
+}) =>
Object.keys(report?.participants ?? {})
.map(Number)
.filter((id) => id !== currentUserAccountID)
@@ -250,11 +250,13 @@ function getInvoicesChatName({
receiverPolicy,
personalDetails,
policies,
+ currentUserAccountID,
}: {
report: OnyxEntry;
receiverPolicy: OnyxEntry;
personalDetails?: Partial;
policies?: Policy[];
+ currentUserAccountID?: number;
}): string {
const invoiceReceiver = report?.invoiceReceiver;
const isIndividual = invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL;
@@ -625,6 +627,7 @@ function computeReportName(
allReportNameValuePairs?: OnyxCollection,
personalDetailsList?: PersonalDetailsList,
reportActions?: OnyxCollection,
+ currentUserAccountID?: number,
): string {
if (!report || !report.reportID) {
return '';
@@ -696,7 +699,7 @@ function computeReportName(
receiverPolicyID = (receiver as {policyID: string}).policyID;
}
const invoiceReceiverPolicy = receiverPolicyID ? policies?.[`${ONYXKEYS.COLLECTION.POLICY}${receiverPolicyID}`] : undefined;
- formattedName = getInvoicesChatName({report, receiverPolicy: invoiceReceiverPolicy, personalDetails: personalDetailsList});
+ formattedName = getInvoicesChatName({report, receiverPolicy: invoiceReceiverPolicy, personalDetails: personalDetailsList, currentUserAccountID});
}
if (isSelfDM(report)) {
@@ -717,7 +720,7 @@ function computeReportName(
}
// Not a room or PolicyExpenseChat, generate title from first 5 other participants
- formattedName = buildReportNameFromParticipantNames({report, personalDetailsList});
+ formattedName = buildReportNameFromParticipantNames({report, personalDetailsList, currentUserAccountID});
const finalName = formattedName ?? report?.reportName ?? '';
diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts
index 568c30bfad92..9fac39fad7d5 100644
--- a/src/libs/ReportUtils.ts
+++ b/src/libs/ReportUtils.ts
@@ -5687,11 +5687,13 @@ function getInvoicesChatName({
receiverPolicy,
personalDetails,
policies,
+ currentUserAccountIDParam,
}: {
report: OnyxEntry;
receiverPolicy: OnyxEntry;
personalDetails?: Partial;
policies?: Policy[];
+ currentUserAccountIDParam?: number;
}): string {
const invoiceReceiver = report?.invoiceReceiver;
const isIndividual = invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL;
@@ -5700,7 +5702,8 @@ function getInvoicesChatName({
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line @typescript-eslint/no-deprecated
const invoiceReceiverPolicy = receiverPolicy ?? getPolicy(invoiceReceiverPolicyID);
- const isCurrentUserReceiver = (isIndividual && invoiceReceiverAccountID === currentUserAccountID) || (!isIndividual && isPolicyAdminPolicyUtils(invoiceReceiverPolicy));
+ const isCurrentUserReceiver =
+ (isIndividual && invoiceReceiverAccountID === (currentUserAccountIDParam ?? currentUserAccountID)) || (!isIndividual && isPolicyAdminPolicyUtils(invoiceReceiverPolicy));
if (isCurrentUserReceiver) {
return getPolicyName({report, policies});
diff --git a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts
index eb4069ce021e..2683dcf131ed 100644
--- a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts
+++ b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts
@@ -68,11 +68,12 @@ export default createOnyxDerivedValueConfig({
ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
ONYXKEYS.COLLECTION.TRANSACTION,
ONYXKEYS.PERSONAL_DETAILS_LIST,
+ ONYXKEYS.SESSION,
ONYXKEYS.COLLECTION.POLICY,
ONYXKEYS.COLLECTION.REPORT_METADATA,
],
compute: (
- [reports, preferredLocale, transactionViolations, reportActions, reportNameValuePairs, transactions, personalDetails, policies],
+ [reports, preferredLocale, transactionViolations, reportActions, reportNameValuePairs, transactions, personalDetails, session, policies],
{currentValue, sourceValues, areAllConnectionsSet},
) => {
if (!areAllConnectionsSet) {
@@ -219,7 +220,7 @@ export default createOnyxDerivedValueConfig({
}
acc[report.reportID] = {
- reportName: report ? computeReportName(report, reports, policies, transactions, reportNameValuePairs, personalDetails, reportActions) : '',
+ reportName: report ? computeReportName(report, reports, policies, transactions, reportNameValuePairs, personalDetails, reportActions, session?.accountID) : '',
isEmpty: generateIsEmptyReport(report, isReportArchived),
brickRoadStatus,
requiresAttention,
diff --git a/src/pages/Search/AdvancedSearchFilters.tsx b/src/pages/Search/AdvancedSearchFilters.tsx
index 11f0638320dd..da695a1f4a4f 100644
--- a/src/pages/Search/AdvancedSearchFilters.tsx
+++ b/src/pages/Search/AdvancedSearchFilters.tsx
@@ -527,9 +527,9 @@ function getFilterExpenseDisplayTitle(filters: Partial, _: LocaleContextProps['translate'], reports?: OnyxCollection) {
+function getFilterInDisplayTitle(filters: Partial, _: LocaleContextProps['translate'], reports?: OnyxCollection, currentUserAccountID?: number) {
return filters.in
- ?.map((id) => computeReportName(reports?.[`${ONYXKEYS.COLLECTION.REPORT}${id}`], reports))
+ ?.map((id) => computeReportName(reports?.[`${ONYXKEYS.COLLECTION.REPORT}${id}`], reports, undefined, undefined, undefined, undefined, undefined, currentUserAccountID))
?.filter(Boolean)
?.join(', ');
}
@@ -548,8 +548,8 @@ function AdvancedSearchFilters() {
const personalDetails = usePersonalDetails();
const [policies = getEmptyObject>>()] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {canBeMissing: false});
-
- const [currentUserLogin] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false, selector: emailSelector});
+ const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true});
+ const currentUserLogin = emailSelector(session);
const taxRates = getAllTaxRates(policies);
@@ -609,7 +609,7 @@ function AdvancedSearchFilters() {
) {
filterTitle = baseFilterConfig[key].getTitle(searchAdvancedFilters[key] ?? [], personalDetails, formatPhoneNumber);
} else if (key === CONST.SEARCH.SYNTAX_FILTER_KEYS.IN) {
- filterTitle = baseFilterConfig[key].getTitle(searchAdvancedFilters, translate, reports);
+ filterTitle = baseFilterConfig[key].getTitle(searchAdvancedFilters, translate, reports, session?.accountID);
} else if (key === CONST.SEARCH.SYNTAX_FILTER_KEYS.POLICY_ID) {
const workspacesData = workspaces.flatMap((value) => value.data);
filterTitle = baseFilterConfig[key].getTitle(searchAdvancedFilters, workspacesData);
diff --git a/src/pages/iou/SplitExpenseEditPage.tsx b/src/pages/iou/SplitExpenseEditPage.tsx
index 96ed74401c3d..ed4d222f4e60 100644
--- a/src/pages/iou/SplitExpenseEditPage.tsx
+++ b/src/pages/iou/SplitExpenseEditPage.tsx
@@ -107,7 +107,8 @@ function SplitExpenseEditPage({route}: SplitExpensePageProps) {
const isSplitAvailable = report && transaction && isSplitAction(currentReport, [transaction], originalTransaction, currentPolicy);
const isCategoryRequired = !!currentPolicy?.requiresCategory;
- const reportName = computeReportName(currentReport);
+ const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true});
+ const reportName = computeReportName(currentReport, undefined, undefined, undefined, undefined, undefined, undefined, session?.accountID);
const isDescriptionRequired = isCategoryDescriptionRequired(policyCategories, splitExpenseDraftTransactionDetails?.category, currentPolicy?.areRulesEnabled);
const shouldShowTags = !!currentPolicy?.areTagsEnabled && !!(transactionTag || hasEnabledTags(policyTagLists));
diff --git a/tests/unit/ReportNameUtilsTest.ts b/tests/unit/ReportNameUtilsTest.ts
index 7790b9eb8c03..ff2800a7ccd2 100644
--- a/tests/unit/ReportNameUtilsTest.ts
+++ b/tests/unit/ReportNameUtilsTest.ts
@@ -82,7 +82,16 @@ describe('ReportNameUtils', () => {
ownerAccountID: currentUserAccountID,
};
- const name = computeReportName(report, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, emptyCollections.reportActions);
+ const name = computeReportName(
+ report,
+ emptyCollections.reports,
+ emptyCollections.policies,
+ undefined,
+ undefined,
+ participantsPersonalDetails,
+ emptyCollections.reportActions,
+ currentUserAccountID,
+ );
expect(name).toBe('Ragnar Lothbrok');
});
@@ -92,7 +101,16 @@ describe('ReportNameUtils', () => {
ownerAccountID: currentUserAccountID,
};
- const name = computeReportName(report, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, emptyCollections.reportActions);
+ const name = computeReportName(
+ report,
+ emptyCollections.reports,
+ emptyCollections.policies,
+ undefined,
+ undefined,
+ participantsPersonalDetails,
+ emptyCollections.reportActions,
+ currentUserAccountID,
+ );
expect(name).toBe('floki@vikings.net');
});
@@ -102,7 +120,16 @@ describe('ReportNameUtils', () => {
ownerAccountID: currentUserAccountID,
};
- const name = computeReportName(report, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, emptyCollections.reportActions);
+ const name = computeReportName(
+ report,
+ emptyCollections.reports,
+ emptyCollections.policies,
+ undefined,
+ undefined,
+ participantsPersonalDetails,
+ emptyCollections.reportActions,
+ currentUserAccountID,
+ );
expect(name).toBe('(833) 240-3627');
});
@@ -114,7 +141,16 @@ describe('ReportNameUtils', () => {
};
await Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, participantsPersonalDetails);
- const name = computeReportName(report, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, emptyCollections.reportActions);
+ const name = computeReportName(
+ report,
+ emptyCollections.reports,
+ emptyCollections.policies,
+ undefined,
+ undefined,
+ participantsPersonalDetails,
+ emptyCollections.reportActions,
+ currentUserAccountID,
+ );
expect(name).toBe('Ragnar, floki@vikings.net, Lagertha, (833) 240-3627');
});
});
@@ -122,7 +158,16 @@ describe('ReportNameUtils', () => {
describe('computeReportName - Admin room', () => {
test('Active admin room', () => {
const report = createAdminRoom(10);
- const name = computeReportName(report, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, emptyCollections.reportActions);
+ const name = computeReportName(
+ report,
+ emptyCollections.reports,
+ emptyCollections.policies,
+ undefined,
+ undefined,
+ participantsPersonalDetails,
+ emptyCollections.reportActions,
+ currentUserAccountID,
+ );
expect(name).toBe('#admins');
});
@@ -140,6 +185,7 @@ describe('ReportNameUtils', () => {
reportNameValuePairs,
participantsPersonalDetails,
emptyCollections.reportActions,
+ currentUserAccountID,
);
expect(nameEn).toBe('#admins (archived)');
@@ -152,6 +198,7 @@ describe('ReportNameUtils', () => {
reportNameValuePairs,
participantsPersonalDetails,
emptyCollections.reportActions,
+ currentUserAccountID,
);
expect(nameEs).toBe('#admins (archivado)');
@@ -167,7 +214,16 @@ describe('ReportNameUtils', () => {
};
await Onyx.merge(ONYXKEYS.PERSONAL_DETAILS_LIST, participantsPersonalDetails);
- const name = computeReportName(report, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, emptyCollections.reportActions);
+ const name = computeReportName(
+ report,
+ emptyCollections.reports,
+ emptyCollections.policies,
+ undefined,
+ undefined,
+ participantsPersonalDetails,
+ emptyCollections.reportActions,
+ currentUserAccountID,
+ );
expect(name).toBe("Ragnar Lothbrok's expenses");
});
});
@@ -180,7 +236,16 @@ describe('ReportNameUtils', () => {
};
await Onyx.merge(ONYXKEYS.SESSION, {accountID: currentUserAccountID, email: 'lagertha2@vikings.net', authTokenType: CONST.AUTH_TOKEN_TYPES.SUPPORT});
- const name = computeReportName(report, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, emptyCollections.reportActions);
+ const name = computeReportName(
+ report,
+ emptyCollections.reports,
+ emptyCollections.policies,
+ undefined,
+ undefined,
+ participantsPersonalDetails,
+ emptyCollections.reportActions,
+ currentUserAccountID,
+ );
expect(name).toBe('Lagertha Lothbrok (you)');
});
});
@@ -193,7 +258,16 @@ describe('ReportNameUtils', () => {
reportName: htmlTaskTitle,
};
- const name = computeReportName(report, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, emptyCollections.reportActions);
+ const name = computeReportName(
+ report,
+ emptyCollections.reports,
+ emptyCollections.policies,
+ undefined,
+ undefined,
+ participantsPersonalDetails,
+ emptyCollections.reportActions,
+ currentUserAccountID,
+ );
expect(name).toBe('heading with link');
});
});
@@ -226,7 +300,7 @@ describe('ReportNameUtils', () => {
};
const expected = translate(CONST.LOCALES.EN, 'iou.submitted', {memo: 'via workflow'});
- const name = computeReportName(thread, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, reportActionsCollection);
+ const name = computeReportName(thread, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, reportActionsCollection, currentUserAccountID);
expect(name).toBe(expected);
});
@@ -254,7 +328,7 @@ describe('ReportNameUtils', () => {
};
const expected = translate(CONST.LOCALES.EN, 'iou.rejectedThisReport');
- const name = computeReportName(thread, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, reportActionsCollection);
+ const name = computeReportName(thread, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, reportActionsCollection, currentUserAccountID);
expect(name).toBe(expected);
});
});
@@ -323,6 +397,7 @@ describe('ReportNameUtils', () => {
reportNameValuePairs,
participantsPersonalDetails,
emptyCollections.reportActions,
+ currentUserAccountID,
);
expect(name).toBe('Ragnar Lothbrok (archived) ');
});
@@ -334,7 +409,7 @@ describe('ReportNameUtils', () => {
...createRegularChat(1000, [currentUserAccountID, 1, 2]),
};
- const name = buildReportNameFromParticipantNames({report, personalDetailsList: participantsPersonalDetails});
+ const name = buildReportNameFromParticipantNames({report, personalDetailsList: participantsPersonalDetails, currentUserAccountID});
expect(name).toBe('Ragnar, floki@vikings.net');
});
@@ -343,7 +418,7 @@ describe('ReportNameUtils', () => {
...createRegularChat(1001, [currentUserAccountID, 1]),
};
- const name = buildReportNameFromParticipantNames({report, personalDetailsList: participantsPersonalDetails});
+ const name = buildReportNameFromParticipantNames({report, personalDetailsList: participantsPersonalDetails, currentUserAccountID});
expect(name).toBe('Ragnar Lothbrok');
});
});
@@ -361,6 +436,7 @@ describe('ReportNameUtils', () => {
report,
receiverPolicy,
personalDetails: participantsPersonalDetails,
+ currentUserAccountID,
});
expect(name).toBe('Personal Workspace');
diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts
index 981c15cf8cd5..012572e5ee69 100644
--- a/tests/unit/ReportUtilsTest.ts
+++ b/tests/unit/ReportUtilsTest.ts
@@ -20,7 +20,7 @@ import getReportURLForCurrentContext from '@libs/Navigation/helpers/getReportURL
import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute';
import Navigation from '@libs/Navigation/Navigation';
import {getOriginalMessage, getReportAction, isWhisperAction} from '@libs/ReportActionsUtils';
-import {buildReportNameFromParticipantNames, computeReportName, getGroupChatName, getPolicyExpenseChatName, getReportName} from '@libs/ReportNameUtils';
+import {buildReportNameFromParticipantNames, computeReportName as computeReportNameOriginal, getGroupChatName, getPolicyExpenseChatName, getReportName} from '@libs/ReportNameUtils';
import type {OptionData} from '@libs/ReportUtils';
import {
buildOptimisticChatReport,
@@ -192,6 +192,16 @@ jest.mock('@libs/Navigation/Navigation', () => ({
const testDate = DateUtils.getDBTime();
const currentUserEmail = 'bjorn@vikings.net';
const currentUserAccountID = 5;
+const computeReportName = (
+ report?: Report,
+ reports?: OnyxCollection,
+ policies?: OnyxCollection,
+ transactions?: OnyxCollection,
+ allReportNameValuePairs?: OnyxCollection,
+ personalDetailsList?: PersonalDetailsList,
+ reportActions?: OnyxCollection,
+ currentUserID = currentUserAccountID,
+) => computeReportNameOriginal(report, reports, policies, transactions, allReportNameValuePairs, personalDetailsList, reportActions, currentUserID);
const participantsPersonalDetails: PersonalDetailsList = {
'1': {
accountID: 1,
@@ -5640,26 +5650,26 @@ describe('ReportUtils', () => {
it('excludes the current user from the report title', () => {
const {report, personalDetails: testPersonalDetails} = generateFakeReportAndParticipantsPersonalDetails({count: currentUserAccountID + 2});
- const result = buildReportNameFromParticipantNames({report, personalDetailsList: testPersonalDetails});
+ const result = buildReportNameFromParticipantNames({report, personalDetailsList: testPersonalDetails, currentUserAccountID});
expect(result).not.toContain('CURRENT');
});
it('limits to a maximum of 5 participants in the title', () => {
const {report, personalDetails: testPersonalDetails} = generateFakeReportAndParticipantsPersonalDetails({count: 10});
- const result = buildReportNameFromParticipantNames({report, personalDetailsList: testPersonalDetails});
+ const result = buildReportNameFromParticipantNames({report, personalDetailsList: testPersonalDetails, currentUserAccountID});
expect(result.split(',').length).toBeLessThanOrEqual(5);
});
it('returns full name if only one participant is present (excluding current user)', () => {
const {report, personalDetails: testPersonalDetails} = generateFakeReportAndParticipantsPersonalDetails({count: 1});
- const result = buildReportNameFromParticipantNames({report, personalDetailsList: testPersonalDetails});
+ const result = buildReportNameFromParticipantNames({report, personalDetailsList: testPersonalDetails, currentUserAccountID});
const {displayName} = fakePersonalDetails[1] ?? {};
expect(result).toEqual(displayName);
});
it('returns an empty string if there are no participants or all are excluded', () => {
const {report, personalDetails: testPersonalDetails} = generateFakeReportAndParticipantsPersonalDetails({start: currentUserAccountID - 1, count: 1});
- const result = buildReportNameFromParticipantNames({report, personalDetailsList: testPersonalDetails});
+ const result = buildReportNameFromParticipantNames({report, personalDetailsList: testPersonalDetails, currentUserAccountID});
expect(result).toEqual('');
});
@@ -5670,7 +5680,7 @@ describe('ReportUtils', () => {
const fourthUser = fakePersonalDetails[4];
const incompleteDetails = {2: secondUser, 4: fourthUser};
- const result = buildReportNameFromParticipantNames({report, personalDetailsList: incompleteDetails});
+ const result = buildReportNameFromParticipantNames({report, personalDetailsList: incompleteDetails, currentUserAccountID});
const expectedNames = [secondUser?.firstName, fourthUser?.firstName].sort();
const resultNames = result.split(', ').sort();
expect(resultNames).toEqual(expect.arrayContaining(expectedNames));
From 2e57fc5dbb1631a6186846f382d25f1eef37c3e2 Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Wed, 31 Dec 2025 01:14:50 +0530
Subject: [PATCH 2/7] Type and prettier fixes
---
tests/unit/OnyxDerivedTest.tsx | 4 ++--
tests/unit/ReportNameUtilsTest.ts | 22 ++++++++++++++++++++--
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/tests/unit/OnyxDerivedTest.tsx b/tests/unit/OnyxDerivedTest.tsx
index b18f1bb3d884..2ea3148a11f2 100644
--- a/tests/unit/OnyxDerivedTest.tsx
+++ b/tests/unit/OnyxDerivedTest.tsx
@@ -129,8 +129,8 @@ 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], {areAllConnectionsSet: true});
- const reportAttributesComputedValue = reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {
+ reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {areAllConnectionsSet: true});
+ const reportAttributesComputedValue = reportAttributes.compute([reports, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined], {
sourceValues: {
[ONYXKEYS.COLLECTION.REPORT]: {
[`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`]: reports[`${ONYXKEYS.COLLECTION.REPORT}${reportID1}`],
diff --git a/tests/unit/ReportNameUtilsTest.ts b/tests/unit/ReportNameUtilsTest.ts
index ff2800a7ccd2..9a8502a106b6 100644
--- a/tests/unit/ReportNameUtilsTest.ts
+++ b/tests/unit/ReportNameUtilsTest.ts
@@ -300,7 +300,16 @@ describe('ReportNameUtils', () => {
};
const expected = translate(CONST.LOCALES.EN, 'iou.submitted', {memo: 'via workflow'});
- const name = computeReportName(thread, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, reportActionsCollection, currentUserAccountID);
+ const name = computeReportName(
+ thread,
+ emptyCollections.reports,
+ emptyCollections.policies,
+ undefined,
+ undefined,
+ participantsPersonalDetails,
+ reportActionsCollection,
+ currentUserAccountID,
+ );
expect(name).toBe(expected);
});
@@ -328,7 +337,16 @@ describe('ReportNameUtils', () => {
};
const expected = translate(CONST.LOCALES.EN, 'iou.rejectedThisReport');
- const name = computeReportName(thread, emptyCollections.reports, emptyCollections.policies, undefined, undefined, participantsPersonalDetails, reportActionsCollection, currentUserAccountID);
+ const name = computeReportName(
+ thread,
+ emptyCollections.reports,
+ emptyCollections.policies,
+ undefined,
+ undefined,
+ participantsPersonalDetails,
+ reportActionsCollection,
+ currentUserAccountID,
+ );
expect(name).toBe(expected);
});
});
From 0524a9c7ec18261d4e37f3d04ff47731e96b6782 Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Wed, 31 Dec 2025 20:06:21 +0530
Subject: [PATCH 3/7] Prettier fix
---
src/components/TransactionItemRow/index.tsx | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx
index 4305d4ac75db..206d860696d2 100644
--- a/src/components/TransactionItemRow/index.tsx
+++ b/src/components/TransactionItemRow/index.tsx
@@ -530,7 +530,11 @@ function TransactionItemRow({
[CONST.SEARCH.TABLE_COLUMNS.TITLE]: (
From fe28b0ab2084a2ad443929e67ef66340d264219e Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Mon, 5 Jan 2026 14:17:16 +0530
Subject: [PATCH 4/7] Make currentUserAccountID a required param
---
src/libs/ReportNameUtils.ts | 5 +++--
src/libs/ReportUtils.ts | 15 +++++++++++----
tests/unit/ReportNameUtilsTest.ts | 1 +
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/libs/ReportNameUtils.ts b/src/libs/ReportNameUtils.ts
index 8582f01ba095..76ffe764c14a 100644
--- a/src/libs/ReportNameUtils.ts
+++ b/src/libs/ReportNameUtils.ts
@@ -256,7 +256,7 @@ function getInvoicesChatName({
receiverPolicy: OnyxEntry;
personalDetails?: Partial;
policies?: Policy[];
- currentUserAccountID?: number;
+ currentUserAccountID: number;
}): string {
const invoiceReceiver = report?.invoiceReceiver;
const isIndividual = invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL;
@@ -699,7 +699,8 @@ function computeReportName(
receiverPolicyID = (receiver as {policyID: string}).policyID;
}
const invoiceReceiverPolicy = receiverPolicyID ? policies?.[`${ONYXKEYS.COLLECTION.POLICY}${receiverPolicyID}`] : undefined;
- formattedName = getInvoicesChatName({report, receiverPolicy: invoiceReceiverPolicy, personalDetails: personalDetailsList, currentUserAccountID});
+ const resolvedCurrentUserAccountID = currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID;
+ formattedName = getInvoicesChatName({report, receiverPolicy: invoiceReceiverPolicy, personalDetails: personalDetailsList, currentUserAccountID: resolvedCurrentUserAccountID});
}
if (isSelfDM(report)) {
diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts
index 9fac39fad7d5..37285451c23d 100644
--- a/src/libs/ReportUtils.ts
+++ b/src/libs/ReportUtils.ts
@@ -5693,7 +5693,7 @@ function getInvoicesChatName({
receiverPolicy: OnyxEntry;
personalDetails?: Partial;
policies?: Policy[];
- currentUserAccountIDParam?: number;
+ currentUserAccountIDParam: number;
}): string {
const invoiceReceiver = report?.invoiceReceiver;
const isIndividual = invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL;
@@ -5702,8 +5702,8 @@ function getInvoicesChatName({
// This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
// eslint-disable-next-line @typescript-eslint/no-deprecated
const invoiceReceiverPolicy = receiverPolicy ?? getPolicy(invoiceReceiverPolicyID);
- const isCurrentUserReceiver =
- (isIndividual && invoiceReceiverAccountID === (currentUserAccountIDParam ?? currentUserAccountID)) || (!isIndividual && isPolicyAdminPolicyUtils(invoiceReceiverPolicy));
+ const resolvedCurrentUserAccountID = currentUserAccountIDParam ?? currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID;
+ const isCurrentUserReceiver = (isIndividual && invoiceReceiverAccountID === resolvedCurrentUserAccountID) || (!isIndividual && isPolicyAdminPolicyUtils(invoiceReceiverPolicy));
if (isCurrentUserReceiver) {
return getPolicyName({report, policies});
@@ -6123,7 +6123,14 @@ function getReportName(
if (isInvoiceRoom(report)) {
// This will be fixed as follow up https://github.com/Expensify/App/pull/75357
// eslint-disable-next-line @typescript-eslint/no-deprecated
- formattedName = getInvoicesChatName({report, receiverPolicy: invoiceReceiverPolicy, personalDetails, policies});
+ const resolvedCurrentUserAccountID = currentUserAccountIDParam ?? currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID;
+ formattedName = getInvoicesChatName({
+ report,
+ receiverPolicy: invoiceReceiverPolicy,
+ personalDetails,
+ policies,
+ currentUserAccountIDParam: resolvedCurrentUserAccountID,
+ });
}
if (isSelfDM(report)) {
diff --git a/tests/unit/ReportNameUtilsTest.ts b/tests/unit/ReportNameUtilsTest.ts
index 9a8502a106b6..a7ed2f6fdfe9 100644
--- a/tests/unit/ReportNameUtilsTest.ts
+++ b/tests/unit/ReportNameUtilsTest.ts
@@ -472,6 +472,7 @@ describe('ReportNameUtils', () => {
report,
receiverPolicy,
personalDetails: participantsPersonalDetails,
+ currentUserAccountID,
});
const normalizedName = name?.replaceAll('\u00A0', ' ');
From 3c93f08f4b2715747978d744e5227ed25d44440e Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Tue, 6 Jan 2026 14:12:59 +0530
Subject: [PATCH 5/7] Update to have account ID as required param at more
places
---
.../MoneyRequestConfirmationListFooter.tsx | 6 ++--
src/components/TransactionItemRow/index.tsx | 2 +-
src/libs/ModifiedExpenseMessage.ts | 7 +++-
src/libs/OptionsListUtils/index.ts | 35 ++++++++++++++++---
src/libs/ReportNameUtils.ts | 7 ++--
src/libs/ReportUtils.ts | 7 ++--
.../OnyxDerived/configs/reportAttributes.ts | 13 ++++++-
src/pages/Search/AdvancedSearchFilters.tsx | 4 +--
src/pages/iou/SplitExpenseEditPage.tsx | 2 +-
tests/unit/ReportNameUtilsTest.ts | 15 ++++++--
10 files changed, 78 insertions(+), 20 deletions(-)
diff --git a/src/components/MoneyRequestConfirmationListFooter.tsx b/src/components/MoneyRequestConfirmationListFooter.tsx
index f113b78f909a..3bd54c8cf0a2 100644
--- a/src/components/MoneyRequestConfirmationListFooter.tsx
+++ b/src/components/MoneyRequestConfirmationListFooter.tsx
@@ -278,6 +278,7 @@ function MoneyRequestConfirmationListFooter({
const {policyForMovingExpensesID, shouldSelectPolicy} = usePolicyForMovingExpenses();
const [currentUserLogin] = useOnyx(ONYXKEYS.SESSION, {selector: emailSelector, canBeMissing: true});
+ const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true});
const isUnreported = transaction?.reportID === CONST.REPORT.UNREPORTED_REPORT_ID;
const isCreatingTrackExpense = action === CONST.IOU.ACTION.CREATE && iouType === CONST.IOU.TYPE.TRACK;
@@ -345,13 +346,14 @@ function MoneyRequestConfirmationListFooter({
return [reportIDToUse, reportToUse];
}, [allReports, shouldUseTransactionReport, transaction?.reportID, outstandingReportID]);
+ const resolvedCurrentUserAccountID = session?.accountID ?? CONST.DEFAULT_NUMBER_ID;
const reportName = useMemo(() => {
- const name = computeReportName(selectedReport, allReports, allPolicies);
+ const name = computeReportName(selectedReport, allReports, allPolicies, undefined, undefined, undefined, undefined, resolvedCurrentUserAccountID);
if (!name) {
return isUnreported ? translate('common.none') : translate('iou.newReport');
}
return name;
- }, [isUnreported, selectedReport, allReports, allPolicies, translate]);
+ }, [isUnreported, selectedReport, allReports, allPolicies, translate, resolvedCurrentUserAccountID]);
const shouldReportBeEditableFromFAB = isUnreported ? allOutstandingReports.length >= 1 : allOutstandingReports.length > 1;
diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx
index 0fed1a621937..a7296b54daf6 100644
--- a/src/components/TransactionItemRow/index.tsx
+++ b/src/components/TransactionItemRow/index.tsx
@@ -544,7 +544,7 @@ function TransactionItemRow({
(environmentURL = url));
let currentUserLogin = '';
+let currentUserAccountID: number | undefined;
Onyx.connectWithoutView({
key: ONYXKEYS.SESSION,
callback: (value) => {
@@ -51,6 +52,7 @@ Onyx.connectWithoutView({
return;
}
currentUserLogin = value?.email ?? '';
+ currentUserAccountID = value?.accountID;
},
});
@@ -168,7 +170,10 @@ function getForExpenseMovedFromSelfDM(translate: LocalizedTranslate, destination
// - A policy expense chat
// - A 1:1 DM
// eslint-disable-next-line @typescript-eslint/no-deprecated
- const reportName = isPolicyExpenseChat(rootParentReport) ? getPolicyExpenseChatName({report: rootParentReport}) : buildReportNameFromParticipantNames({report: rootParentReport});
+ const resolvedCurrentUserAccountID = currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID;
+ const reportName = isPolicyExpenseChat(rootParentReport)
+ ? getPolicyExpenseChatName({report: rootParentReport})
+ : buildReportNameFromParticipantNames({report: rootParentReport, currentUserAccountID: resolvedCurrentUserAccountID});
const policyName = getPolicyName({report: rootParentReport, returnEmptyIfNotFound: true});
// If we can't determine either the report name or policy name, return the default message
if (isEmpty(policyName) && !reportName) {
diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts
index cc0afa464b04..02d3a5e78999 100644
--- a/src/libs/OptionsListUtils/index.ts
+++ b/src/libs/OptionsListUtils/index.ts
@@ -650,7 +650,7 @@ function getLastMessageTextForReport({
: undefined;
// For workspace chats, use the report title
if (reportUtilsIsPolicyExpenseChat(report) && !isEmptyObject(iouReport)) {
- const reportName = computeReportName(iouReport, undefined, undefined, undefined, undefined, undefined, undefined, currentUserAccountID);
+ const reportName = computeReportName(iouReport, undefined, undefined, undefined, undefined, undefined, undefined, currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID);
lastMessageTextFromReport = formatReportLastMessageText(reportName);
} else {
const reportPreviewMessage = getReportPreviewMessage(
@@ -924,7 +924,16 @@ function createOption(
: getAlternateText(result, {showChatPreviewLine, forcePolicyNamePreview}, !!result.private_isArchived, lastActorDetails);
const personalDetailsForCompute: PersonalDetailsList | undefined = personalDetails ?? undefined;
- const computedReportName = computeReportName(report, allReports, allPolicies, undefined, allReportNameValuePairs, personalDetailsForCompute, allReportActions, currentUserAccountID);
+ const computedReportName = computeReportName(
+ report,
+ allReports,
+ allPolicies,
+ undefined,
+ allReportNameValuePairs,
+ personalDetailsForCompute,
+ allReportActions,
+ currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID,
+ );
reportName = showPersonalDetails
? getDisplayNameForParticipant({accountID: accountIDs.at(0), formatPhoneNumber: formatPhoneNumberPhoneUtils}) || formatPhoneNumberPhoneUtils(personalDetail?.login ?? '')
: computedReportName;
@@ -986,7 +995,16 @@ function getReportOption(participant: Participant, reportAttributesDerived?: Rep
// eslint-disable-next-line @typescript-eslint/no-deprecated
option.alternateText = translateLocal('reportActionsView.yourSpace');
} else if (option.isInvoiceRoom) {
- option.text = computeReportName(report, undefined, undefined, undefined, allReportNameValuePairs, allPersonalDetails, undefined, currentUserAccountID);
+ option.text = computeReportName(
+ report,
+ undefined,
+ undefined,
+ undefined,
+ allReportNameValuePairs,
+ allPersonalDetails,
+ undefined,
+ currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID,
+ );
// eslint-disable-next-line @typescript-eslint/no-deprecated
option.alternateText = translateLocal('workspace.common.invoices');
} else {
@@ -1035,7 +1053,16 @@ function getReportDisplayOption(report: OnyxEntry, unknownUserDetails: O
// eslint-disable-next-line @typescript-eslint/no-deprecated
option.alternateText = translateLocal('reportActionsView.yourSpace');
} else if (option.isInvoiceRoom) {
- option.text = computeReportName(report, undefined, undefined, undefined, allReportNameValuePairs, allPersonalDetails, undefined, currentUserAccountID);
+ option.text = computeReportName(
+ report,
+ undefined,
+ undefined,
+ undefined,
+ allReportNameValuePairs,
+ allPersonalDetails,
+ undefined,
+ currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID,
+ );
// eslint-disable-next-line @typescript-eslint/no-deprecated
option.alternateText = translateLocal('workspace.common.invoices');
} else if (unknownUserDetails) {
diff --git a/src/libs/ReportNameUtils.ts b/src/libs/ReportNameUtils.ts
index 203125c0aaea..b3496136e0f4 100644
--- a/src/libs/ReportNameUtils.ts
+++ b/src/libs/ReportNameUtils.ts
@@ -141,7 +141,7 @@ const buildReportNameFromParticipantNames = ({
}: {
report: OnyxEntry;
personalDetailsList?: Partial;
- currentUserAccountID?: number;
+ currentUserAccountID: number;
}) =>
Object.keys(report?.participants ?? {})
.map(Number)
@@ -655,7 +655,7 @@ function computeReportName(
allReportNameValuePairs?: OnyxCollection,
personalDetailsList?: PersonalDetailsList,
reportActions?: OnyxCollection,
- currentUserAccountID?: number,
+ currentUserAccountID: number,
): string {
if (!report || !report.reportID) {
return '';
@@ -749,7 +749,8 @@ function computeReportName(
}
// Not a room or PolicyExpenseChat, generate title from first 5 other participants
- formattedName = buildReportNameFromParticipantNames({report, personalDetailsList, currentUserAccountID});
+ const resolvedCurrentUserAccountID = currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID;
+ formattedName = buildReportNameFromParticipantNames({report, personalDetailsList, currentUserAccountID: resolvedCurrentUserAccountID});
const finalName = formattedName ?? report?.reportName ?? '';
diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts
index 3fd345a3aa32..fb10ade40b33 100644
--- a/src/libs/ReportUtils.ts
+++ b/src/libs/ReportUtils.ts
@@ -5948,13 +5948,13 @@ function getReportName(
}
if (isInvoiceRoom(report)) {
- const resolvedCurrentUserAccountID = currentUserAccountIDParam ?? currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID;
+ const resolvedCurrentUserAccountID = currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID;
formattedName = getInvoicesChatName({
report,
receiverPolicy: invoiceReceiverPolicy,
personalDetails,
policies,
- currentUserAccountIDParam: resolvedCurrentUserAccountID,
+ currentUserAccountID: resolvedCurrentUserAccountID,
});
}
@@ -5976,7 +5976,8 @@ function getReportName(
}
// Not a room or PolicyExpenseChat, generate title from first 5 other participants
- formattedName = buildReportNameFromParticipantNames({report, personalDetailsList: personalDetails});
+ const resolvedCurrentUserAccountID = currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID;
+ formattedName = buildReportNameFromParticipantNames({report, personalDetailsList: personalDetails, currentUserAccountID: resolvedCurrentUserAccountID});
const finalName = formattedName || (report?.reportName ?? '');
diff --git a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts
index 2683dcf131ed..c9de2825d792 100644
--- a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts
+++ b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts
@@ -220,7 +220,18 @@ export default createOnyxDerivedValueConfig({
}
acc[report.reportID] = {
- reportName: report ? computeReportName(report, reports, policies, transactions, reportNameValuePairs, personalDetails, reportActions, session?.accountID) : '',
+ reportName: report
+ ? computeReportName(
+ report,
+ reports,
+ policies,
+ transactions,
+ reportNameValuePairs,
+ personalDetails,
+ reportActions,
+ session?.accountID ?? CONST.DEFAULT_NUMBER_ID,
+ )
+ : '',
isEmpty: generateIsEmptyReport(report, isReportArchived),
brickRoadStatus,
requiresAttention,
diff --git a/src/pages/Search/AdvancedSearchFilters.tsx b/src/pages/Search/AdvancedSearchFilters.tsx
index da695a1f4a4f..88092e4f0c02 100644
--- a/src/pages/Search/AdvancedSearchFilters.tsx
+++ b/src/pages/Search/AdvancedSearchFilters.tsx
@@ -527,7 +527,7 @@ function getFilterExpenseDisplayTitle(filters: Partial, _: LocaleContextProps['translate'], reports?: OnyxCollection, currentUserAccountID?: number) {
+function getFilterInDisplayTitle(filters: Partial, _: LocaleContextProps['translate'], reports: OnyxCollection | undefined, currentUserAccountID: number) {
return filters.in
?.map((id) => computeReportName(reports?.[`${ONYXKEYS.COLLECTION.REPORT}${id}`], reports, undefined, undefined, undefined, undefined, undefined, currentUserAccountID))
?.filter(Boolean)
@@ -609,7 +609,7 @@ function AdvancedSearchFilters() {
) {
filterTitle = baseFilterConfig[key].getTitle(searchAdvancedFilters[key] ?? [], personalDetails, formatPhoneNumber);
} else if (key === CONST.SEARCH.SYNTAX_FILTER_KEYS.IN) {
- filterTitle = baseFilterConfig[key].getTitle(searchAdvancedFilters, translate, reports, session?.accountID);
+ filterTitle = baseFilterConfig[key].getTitle(searchAdvancedFilters, translate, reports, session?.accountID ?? CONST.DEFAULT_NUMBER_ID);
} else if (key === CONST.SEARCH.SYNTAX_FILTER_KEYS.POLICY_ID) {
const workspacesData = workspaces.flatMap((value) => value.data);
filterTitle = baseFilterConfig[key].getTitle(searchAdvancedFilters, workspacesData);
diff --git a/src/pages/iou/SplitExpenseEditPage.tsx b/src/pages/iou/SplitExpenseEditPage.tsx
index ed4d222f4e60..d6cc66695c18 100644
--- a/src/pages/iou/SplitExpenseEditPage.tsx
+++ b/src/pages/iou/SplitExpenseEditPage.tsx
@@ -108,7 +108,7 @@ function SplitExpenseEditPage({route}: SplitExpensePageProps) {
const isCategoryRequired = !!currentPolicy?.requiresCategory;
const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true});
- const reportName = computeReportName(currentReport, undefined, undefined, undefined, undefined, undefined, undefined, session?.accountID);
+ const reportName = computeReportName(currentReport, undefined, undefined, undefined, undefined, undefined, undefined, session?.accountID ?? CONST.DEFAULT_NUMBER_ID);
const isDescriptionRequired = isCategoryDescriptionRequired(policyCategories, splitExpenseDraftTransactionDetails?.category, currentPolicy?.areRulesEnabled);
const shouldShowTags = !!currentPolicy?.areTagsEnabled && !!(transactionTag || hasEnabledTags(policyTagLists));
diff --git a/tests/unit/ReportNameUtilsTest.ts b/tests/unit/ReportNameUtilsTest.ts
index a7ed2f6fdfe9..9b45063e6345 100644
--- a/tests/unit/ReportNameUtilsTest.ts
+++ b/tests/unit/ReportNameUtilsTest.ts
@@ -1,8 +1,9 @@
import Onyx from 'react-native-onyx';
+import type {OnyxCollection} from 'react-native-onyx';
import {translate} from '@libs/Localize';
import {
buildReportNameFromParticipantNames,
- computeReportName,
+ computeReportName as computeReportNameOriginal,
getGroupChatName,
getInvoicePayerName,
getInvoicesChatName,
@@ -12,7 +13,7 @@ import {
import CONST from '@src/CONST';
import IntlStore from '@src/languages/IntlStore';
import ONYXKEYS from '@src/ONYXKEYS';
-import type {PersonalDetailsList, Policy, Report, ReportAction, ReportActions, ReportAttributesDerivedValue, ReportNameValuePairs} from '@src/types/onyx';
+import type {PersonalDetailsList, Policy, Report, ReportAction, ReportActions, ReportAttributesDerivedValue, ReportNameValuePairs, Transaction} from '@src/types/onyx';
import {createAdminRoom, createPolicyExpenseChat, createRegularChat, createRegularTaskReport, createSelfDM, createWorkspaceThread} from '../utils/collections/reports';
import {fakePersonalDetails} from '../utils/LHNTestUtils';
import {formatPhoneNumber} from '../utils/TestHelper';
@@ -20,6 +21,16 @@ import waitForBatchedUpdates from '../utils/waitForBatchedUpdates';
describe('ReportNameUtils', () => {
const currentUserAccountID = 5;
+ const computeReportName = (
+ report?: Report,
+ reports?: OnyxCollection,
+ policies?: OnyxCollection,
+ transactions?: OnyxCollection,
+ allReportNameValuePairs?: OnyxCollection,
+ personalDetailsList?: PersonalDetailsList,
+ reportActions?: OnyxCollection,
+ currentUserID = currentUserAccountID,
+ ) => computeReportNameOriginal(report, reports, policies, transactions, allReportNameValuePairs, personalDetailsList, reportActions, currentUserID);
const participantsPersonalDetails: PersonalDetailsList = [
{
accountID: 1,
From ff2d024836e7873969f5fc33febaf944138ab17a Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Tue, 6 Jan 2026 18:01:46 +0530
Subject: [PATCH 6/7] Make currentUserAccountID optional in computeReportName
---
src/libs/ReportNameUtils.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libs/ReportNameUtils.ts b/src/libs/ReportNameUtils.ts
index b3496136e0f4..3e45fec477b1 100644
--- a/src/libs/ReportNameUtils.ts
+++ b/src/libs/ReportNameUtils.ts
@@ -655,7 +655,7 @@ function computeReportName(
allReportNameValuePairs?: OnyxCollection,
personalDetailsList?: PersonalDetailsList,
reportActions?: OnyxCollection,
- currentUserAccountID: number,
+ currentUserAccountID?: number,
): string {
if (!report || !report.reportID) {
return '';
From 8b029ef57f28ce46c19e0ced1310aa667c40d86e Mon Sep 17 00:00:00 2001
From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com>
Date: Tue, 6 Jan 2026 18:17:11 +0530
Subject: [PATCH 7/7] Prettier fixes
---
src/libs/OptionsListUtils/index.ts | 22 ++-----------------
.../OnyxDerived/configs/reportAttributes.ts | 11 +---------
2 files changed, 3 insertions(+), 30 deletions(-)
diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts
index 02d3a5e78999..273c2c124f0d 100644
--- a/src/libs/OptionsListUtils/index.ts
+++ b/src/libs/OptionsListUtils/index.ts
@@ -995,16 +995,7 @@ function getReportOption(participant: Participant, reportAttributesDerived?: Rep
// eslint-disable-next-line @typescript-eslint/no-deprecated
option.alternateText = translateLocal('reportActionsView.yourSpace');
} else if (option.isInvoiceRoom) {
- option.text = computeReportName(
- report,
- undefined,
- undefined,
- undefined,
- allReportNameValuePairs,
- allPersonalDetails,
- undefined,
- currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID,
- );
+ option.text = computeReportName(report, undefined, undefined, undefined, allReportNameValuePairs, allPersonalDetails, undefined, currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID);
// eslint-disable-next-line @typescript-eslint/no-deprecated
option.alternateText = translateLocal('workspace.common.invoices');
} else {
@@ -1053,16 +1044,7 @@ function getReportDisplayOption(report: OnyxEntry, unknownUserDetails: O
// eslint-disable-next-line @typescript-eslint/no-deprecated
option.alternateText = translateLocal('reportActionsView.yourSpace');
} else if (option.isInvoiceRoom) {
- option.text = computeReportName(
- report,
- undefined,
- undefined,
- undefined,
- allReportNameValuePairs,
- allPersonalDetails,
- undefined,
- currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID,
- );
+ option.text = computeReportName(report, undefined, undefined, undefined, allReportNameValuePairs, allPersonalDetails, undefined, currentUserAccountID ?? CONST.DEFAULT_NUMBER_ID);
// eslint-disable-next-line @typescript-eslint/no-deprecated
option.alternateText = translateLocal('workspace.common.invoices');
} else if (unknownUserDetails) {
diff --git a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts
index c9de2825d792..e998c18507f5 100644
--- a/src/libs/actions/OnyxDerived/configs/reportAttributes.ts
+++ b/src/libs/actions/OnyxDerived/configs/reportAttributes.ts
@@ -221,16 +221,7 @@ export default createOnyxDerivedValueConfig({
acc[report.reportID] = {
reportName: report
- ? computeReportName(
- report,
- reports,
- policies,
- transactions,
- reportNameValuePairs,
- personalDetails,
- reportActions,
- session?.accountID ?? CONST.DEFAULT_NUMBER_ID,
- )
+ ? computeReportName(report, reports, policies, transactions, reportNameValuePairs, personalDetails, reportActions, session?.accountID ?? CONST.DEFAULT_NUMBER_ID)
: '',
isEmpty: generateIsEmptyReport(report, isReportArchived),
brickRoadStatus,