From a17b0a37e508e09cb4af0a5814403d8993aec269 Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Thu, 15 Jan 2026 15:29:10 +0530 Subject: [PATCH 1/3] Refactor: removed getGroupChatDraft and using isLoadingOnyxValue in place --- src/libs/ReportUtils.ts | 12 ------------ src/pages/GroupChatNameEditPage.tsx | 23 +++++++++++++++++++---- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 2c00bc38705e..71eb240a02a6 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -38,7 +38,6 @@ import type { BankAccountList, Beta, IntroSelected, - NewGroupChatDraft, OnyxInputOrEntry, OutstandingReportsByPolicyIDDerivedValue, PersonalDetails, @@ -1212,12 +1211,6 @@ Onyx.connectWithoutView({ }, }); -let newGroupChatDraft: OnyxEntry; -Onyx.connectWithoutView({ - key: ONYXKEYS.NEW_GROUP_CHAT_DRAFT, - callback: (value) => (newGroupChatDraft = value), -}); - let cachedSelfDMReportID: OnyxEntry; Onyx.connectWithoutView({ key: ONYXKEYS.SELF_DM_REPORT_ID, @@ -12478,10 +12471,6 @@ function isWaitingForSubmissionFromCurrentUser(chatReport: OnyxEntry, po return chatReport?.isOwnPolicyExpenseChat && !policy?.harvesting?.enabled; } -function getGroupChatDraft() { - return newGroupChatDraft; -} - function getChatListItemReportName(action: ReportAction & {reportName?: string}, report: Report | undefined): string { if (report && isInvoiceReport(report)) { const properInvoiceReport = report; @@ -13257,7 +13246,6 @@ export { buildOptimisticResolvedDuplicatesReportAction, getTitleReportField, getReportFieldsByPolicyID, - getGroupChatDraft, getChatListItemReportName, buildOptimisticMovedTransactionAction, populateOptimisticReportFormula, diff --git a/src/pages/GroupChatNameEditPage.tsx b/src/pages/GroupChatNameEditPage.tsx index 1cd289c4f84a..bb0399c7f94f 100644 --- a/src/pages/GroupChatNameEditPage.tsx +++ b/src/pages/GroupChatNameEditPage.tsx @@ -13,7 +13,6 @@ import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {NewChatNavigatorParamList} from '@libs/Navigation/types'; import {getGroupChatName} from '@libs/ReportNameUtils'; -import {getGroupChatDraft} from '@libs/ReportUtils'; import StringUtils from '@libs/StringUtils'; import {setGroupDraft, updateChatName} from '@userActions/Report'; import CONST from '@src/CONST'; @@ -21,19 +20,24 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import INPUT_IDS from '@src/types/form/NewChatNameForm'; -import type {Report as ReportOnyxType} from '@src/types/onyx'; +import type {Report as ReportOnyxType, NewGroupChatDraft} from '@src/types/onyx'; import type {Errors} from '@src/types/onyx/OnyxCommon'; +import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; type GroupChatNameEditPageProps = Partial> & { report?: ReportOnyxType; }; -function GroupChatNameEditPage({report}: GroupChatNameEditPageProps) { +type GroupChatNameEditInternalProps = { + report?: ReportOnyxType; + groupChatDraft?: NewGroupChatDraft; +}; + +function GroupChatNameInternal({report, groupChatDraft}: GroupChatNameEditInternalProps) { // If we have a report this means we are using this page to update an existing Group Chat name // In this case its better to use empty string as the reportID if there is no reportID const reportID = report?.reportID; const isUpdatingExistingReport = !!reportID; - const [groupChatDraft = getGroupChatDraft()] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT, {canBeMissing: true}); const styles = useThemeStyles(); const {translate, formatPhoneNumber} = useLocalize(); @@ -111,4 +115,15 @@ function GroupChatNameEditPage({report}: GroupChatNameEditPageProps) { ); } +function GroupChatNameEditPage({report}: GroupChatNameEditPageProps) { + const [groupChatDraft, groupChatDraftMetadata] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT, {canBeMissing: true}); + const isLoading = isLoadingOnyxValue(groupChatDraftMetadata); + + if (isLoading) { + return null; + } + + return ; +} + export default GroupChatNameEditPage; From e0d7ad026dfa2d665d64a97683c3e27b1fe20b9e Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Thu, 15 Jan 2026 15:29:33 +0530 Subject: [PATCH 2/3] Prettier --- src/pages/GroupChatNameEditPage.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/GroupChatNameEditPage.tsx b/src/pages/GroupChatNameEditPage.tsx index bb0399c7f94f..6b1413aa3dff 100644 --- a/src/pages/GroupChatNameEditPage.tsx +++ b/src/pages/GroupChatNameEditPage.tsx @@ -20,7 +20,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import INPUT_IDS from '@src/types/form/NewChatNameForm'; -import type {Report as ReportOnyxType, NewGroupChatDraft} from '@src/types/onyx'; +import type {NewGroupChatDraft, Report as ReportOnyxType} from '@src/types/onyx'; import type {Errors} from '@src/types/onyx/OnyxCommon'; import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; @@ -123,7 +123,12 @@ function GroupChatNameEditPage({report}: GroupChatNameEditPageProps) { return null; } - return ; + return ( + + ); } export default GroupChatNameEditPage; From 6543c1bbfef869a5d35c2452d96c07eb7335c5b3 Mon Sep 17 00:00:00 2001 From: Shubham Agrawal Date: Tue, 20 Jan 2026 12:15:42 +0530 Subject: [PATCH 3/3] Simplified logic --- src/pages/GroupChatNameEditPage.tsx | 30 +++++++---------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/pages/GroupChatNameEditPage.tsx b/src/pages/GroupChatNameEditPage.tsx index 6b1413aa3dff..2c69af75c0cf 100644 --- a/src/pages/GroupChatNameEditPage.tsx +++ b/src/pages/GroupChatNameEditPage.tsx @@ -20,7 +20,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import INPUT_IDS from '@src/types/form/NewChatNameForm'; -import type {NewGroupChatDraft, Report as ReportOnyxType} from '@src/types/onyx'; +import type {Report as ReportOnyxType} from '@src/types/onyx'; import type {Errors} from '@src/types/onyx/OnyxCommon'; import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; @@ -28,16 +28,12 @@ type GroupChatNameEditPageProps = Partial - ); -} - export default GroupChatNameEditPage;