Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,7 @@ const CONST = {
NSQS: 'nsqs',
CUSTOM_RULES: 'customRules',
TABLE_REPORT_VIEW: 'tableReportView',
HELP_SIDE_PANEL: 'newDotHelpSidePanel',
RECEIPT_LINE_ITEMS: 'receiptLineItems',
},
BUTTON_STATES: {
Expand Down
8 changes: 5 additions & 3 deletions src/hooks/useSidePane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import variables from '@styles/variables';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type * as OnyxTypes from '@src/types/onyx';
import usePermissions from './usePermissions';
import useResponsiveLayout from './useResponsiveLayout';
import useWindowDimensions from './useWindowDimensions';

Expand All @@ -30,6 +31,7 @@ function useSidePane() {
const {windowWidth} = useWindowDimensions();

const [sidePaneNVP] = useOnyx(ONYXKEYS.NVP_SIDE_PANE);
const {canUseHelpSidePanel} = usePermissions();
const [language] = useOnyx(ONYXKEYS.NVP_PREFERRED_LOCALE);
const [isModalCenteredVisible = false] = useOnyx(ONYXKEYS.MODAL, {
selector: (modal) =>
Expand All @@ -38,7 +40,7 @@ function useSidePane() {
modal?.type === CONST.MODAL.MODAL_TYPE.CENTERED_SMALL,
});
const isLanguageUnsupported = language !== CONST.LOCALES.EN;
const isPaneHidden = isSidePaneHidden(sidePaneNVP, isExtraLargeScreenWidth) || isLanguageUnsupported || isModalCenteredVisible;
const isPaneHidden = isSidePaneHidden(sidePaneNVP, isExtraLargeScreenWidth) || isLanguageUnsupported || isModalCenteredVisible || !canUseHelpSidePanel;

const sidePaneWidth = shouldUseNarrowLayout ? windowWidth : variables.sideBarWidth;
const shouldApplySidePaneOffset = isExtraLargeScreenWidth && !isPaneHidden;
Expand All @@ -50,10 +52,10 @@ function useSidePane() {
const shouldHideToolTip = isExtraLargeScreenWidth ? isAnimatingExtraLargeScree : !shouldHideSidePane;

// The help button is hidden when:
// - side pane nvp is not set
// - the user is not part of the corresponding beta
// - side pane is displayed currently
// - language is unsupported
const shouldHideHelpButton = !sidePaneNVP || !isPaneHidden || isLanguageUnsupported;
const shouldHideHelpButton = !canUseHelpSidePanel || !isPaneHidden || isLanguageUnsupported;

const sidePaneOffset = useRef(new Animated.Value(shouldApplySidePaneOffset ? variables.sideBarWidth : 0));
const sidePaneTranslateX = useRef(new Animated.Value(isPaneHidden ? sidePaneWidth : 0));
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ function canUseTableReportView(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.TABLE_REPORT_VIEW) || canUseAllBetas(betas);
}

function canUseHelpSidePanel(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.HELP_SIDE_PANEL) || canUseAllBetas(betas);
}

function canUseTalkToAISales(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.NEW_DOT_TALK_TO_AI_SALES) || canUseAllBetas(betas);
}
Expand All @@ -79,6 +83,7 @@ export default {
canUseNSQS,
canUseCustomRules,
canUseTableReportView,
canUseHelpSidePanel,
canUseTalkToAISales,
canUseProhibitedExpenses,
};