Skip to content

Commit 6b54e15

Browse files
MelvinBotsuneox
andcommitted
Hide Private Notes behind PRIVATE_NOTES beta flag
Gate the Private Notes UI entry points in ReportDetailsPage and ProfilePage behind isBetaEnabled(CONST.BETAS.PRIVATE_NOTES) instead of removing the feature code entirely. Also skip the getReportPrivateNote API fetch when the beta is disabled. Since no backend sets this beta on any account, Private Notes is effectively hidden for all users. The backend should also add 'privateNotes' to the explicitOnly beta configuration so that BETAS.ALL does not enable it. Co-authored-by: Cong Pham <suneox@users.noreply.github.com>
1 parent cfe190a commit 6b54e15

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/CONST/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,7 @@ const CONST = {
887887
BULK_EDIT: 'bulkEdit',
888888
NEW_MANUAL_EXPENSE_FLOW: 'newManualExpenseFlow',
889889
BULK_SUBMIT_APPROVE_PAY: 'bulkSubmitApprovePay',
890+
PRIVATE_NOTES: 'privateNotes',
890891
},
891892
BUTTON_STATES: {
892893
DEFAULT: 'default',

src/pages/ProfilePage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
2121
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
2222
import useLocalize from '@hooks/useLocalize';
2323
import useOnyx from '@hooks/useOnyx';
24+
import usePermissions from '@hooks/usePermissions';
2425
import useThemeStyles from '@hooks/useThemeStyles';
2526
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
2627
import Navigation from '@libs/Navigation/Navigation';
@@ -90,6 +91,7 @@ function ProfilePage({route}: ProfilePageProps) {
9091

9192
const styles = useThemeStyles();
9293
const {translate, formatPhoneNumber} = useLocalize();
94+
const {isBetaEnabled} = usePermissions();
9395

9496
const isValidAccountID = isValidAccountRoute(accountID);
9597
const loginParams = route.params?.login;
@@ -266,7 +268,7 @@ function ProfilePage({route}: ProfilePageProps) {
266268
}}
267269
/>
268270
)}
269-
{!isEmptyObject(report) && !!report.reportID && !isCurrentUser && (
271+
{isBetaEnabled(CONST.BETAS.PRIVATE_NOTES) && !isEmptyObject(report) && !!report.reportID && !isCurrentUser && (
270272
<MenuItem
271273
title={`${translate('privateNotes.title')}`}
272274
titleStyle={styles.flex1}

src/pages/ReportDetailsPage.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import useNetwork from '@hooks/useNetwork';
3838
import useOnyx from '@hooks/useOnyx';
3939
import usePaginatedReportActions from '@hooks/usePaginatedReportActions';
4040
import useParentReportAction from '@hooks/useParentReportAction';
41+
import usePermissions from '@hooks/usePermissions';
4142
import usePreferredPolicy from '@hooks/usePreferredPolicy';
4243
import useReportAttributes from '@hooks/useReportAttributes';
4344
import useReportIsArchived from '@hooks/useReportIsArchived';
@@ -162,6 +163,7 @@ type CaseID = ValueOf<typeof CASES>;
162163
function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetailsPageProps) {
163164
const {translate, localeCompare, formatPhoneNumber} = useLocalize();
164165
const {isOffline} = useNetwork();
166+
const {isBetaEnabled} = usePermissions();
165167
const {isRestrictedToPreferredPolicy, preferredPolicyID} = usePreferredPolicy();
166168
const activePolicy = useActivePolicy();
167169
const styles = useThemeStyles();
@@ -323,14 +325,16 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
323325
const reportAttributes = useReportAttributes();
324326
const isWorkspaceChat = useMemo(() => isWorkspaceChatUtil(report?.chatType ?? ''), [report?.chatType]);
325327

328+
const isPrivateNotesEnabled = isBetaEnabled(CONST.BETAS.PRIVATE_NOTES);
329+
326330
useEffect(() => {
327-
// Do not fetch private notes if isLoadingPrivateNotes is already defined, or if the network is offline, or if the report is a self DM.
328-
if (isPrivateNotesFetchTriggered || isOffline || isSelfDM) {
331+
// Do not fetch private notes if the beta is disabled, isLoadingPrivateNotes is already defined, the network is offline, or if the report is a self DM.
332+
if (!isPrivateNotesEnabled || isPrivateNotesFetchTriggered || isOffline || isSelfDM) {
329333
return;
330334
}
331335

332336
getReportPrivateNote(report?.reportID);
333-
}, [report?.reportID, isOffline, isPrivateNotesFetchTriggered, isSelfDM]);
337+
}, [report?.reportID, isOffline, isPrivateNotesFetchTriggered, isSelfDM, isPrivateNotesEnabled]);
334338

335339
const leaveChat = useCallback(() => {
336340
if (isRootGroupChat) {
@@ -526,8 +530,8 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
526530
}
527531
}
528532

529-
// Prevent displaying private notes option for threads and task reports
530-
if (!isChatThread && !isMoneyRequestReport && !isInvoiceReport && !isTaskReport) {
533+
// Prevent displaying private notes option for threads and task reports, or when the beta is disabled
534+
if (isBetaEnabled(CONST.BETAS.PRIVATE_NOTES) && !isChatThread && !isMoneyRequestReport && !isInvoiceReport && !isTaskReport) {
531535
items.push({
532536
key: CONST.REPORT_DETAILS_MENU_ITEM.PRIVATE_NOTES,
533537
translationKey: 'privateNotes.title',
@@ -651,6 +655,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
651655
ownerBillingGracePeriodEnd,
652656
iouTransaction,
653657
delegateEmail,
658+
isBetaEnabled,
654659
]);
655660

656661
const displayNamesWithTooltips = useMemo(() => {

0 commit comments

Comments
 (0)