diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 3eb07cbd3a59..51f8ddaa1a65 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -38,7 +38,6 @@ import type { BankAccountList, Beta, IntroSelected, - NewGroupChatDraft, OnyxInputOrEntry, OutstandingReportsByPolicyIDDerivedValue, PersonalDetails, @@ -1223,12 +1222,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, @@ -12580,10 +12573,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; @@ -13374,7 +13363,6 @@ export { buildOptimisticResolvedDuplicatesReportAction, getTitleReportField, getReportFieldsByPolicyID, - getGroupChatDraft, getChatListItemReportName, buildOptimisticMovedTransactionAction, populateOptimisticReportFormula, diff --git a/src/pages/GroupChatNameEditPage.tsx b/src/pages/GroupChatNameEditPage.tsx index a282eb1dc215..738b01f38f29 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'; @@ -23,6 +22,7 @@ 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 {Errors} from '@src/types/onyx/OnyxCommon'; +import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; type GroupChatNameEditPageProps = Partial> & { report?: ReportOnyxType; @@ -33,7 +33,7 @@ function GroupChatNameEditPage({report}: GroupChatNameEditPageProps) { // 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 [groupChatDraft, groupChatDraftMetadata] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT, {canBeMissing: true}); const styles = useThemeStyles(); const {translate, formatPhoneNumber} = useLocalize(); @@ -68,6 +68,10 @@ function GroupChatNameEditPage({report}: GroupChatNameEditPageProps) { Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.goBack(ROUTES.NEW_CHAT_CONFIRM)); }; + if (isLoadingOnyxValue(groupChatDraftMetadata)) { + return null; + } + return (