Skip to content
Merged
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 @@ -777,6 +777,7 @@ const CONST = {
NSQS: 'nsqs',
CUSTOM_RULES: 'customRules',
TABLE_REPORT_VIEW: 'tableReportView',
HELP_SIDE_PANEL: 'newDotHelpSidePanel',
RECEIPT_LINE_ITEMS: 'receiptLineItems',
},
BUTTON_STATES: {
Expand Down
21 changes: 7 additions & 14 deletions src/hooks/useSidePane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function useSidePaneDisplayStatus() {
const {isExtraLargeScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
const [sidePaneNVP] = useOnyx(ONYXKEYS.NVP_SIDE_PANE);
const [language] = useOnyx(ONYXKEYS.NVP_PREFERRED_LOCALE);
const [canUseHelpSidePanel = false] = useOnyx(ONYXKEYS.BETAS, {selector: (betas) => !!betas?.includes(CONST.BETAS.HELP_SIDE_PANEL)});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why we don't use usePermissions() here? Thanks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why but usePermissions was breaking GH checks here

const [isModalCenteredVisible = false] = useOnyx(ONYXKEYS.MODAL, {
selector: (modal) =>
modal?.type === CONST.MODAL.MODAL_TYPE.CENTERED_SWIPABLE_TO_RIGHT ||
Expand All @@ -35,14 +36,14 @@ function useSidePaneDisplayStatus() {
// - NVP is not set or it is false
// - language is unsupported
// - modal centered is visible
const shouldHideSidePane = !isSidePaneVisible || isLanguageUnsupported || isModalCenteredVisible;
const isSidePaneHiddenOrLargeScreen = !isSidePaneVisible || isLanguageUnsupported || isExtraLargeScreenWidth;
const shouldHideSidePane = !isSidePaneVisible || isLanguageUnsupported || isModalCenteredVisible || !canUseHelpSidePanel;
const isSidePaneHiddenOrLargeScreen = !isSidePaneVisible || isLanguageUnsupported || isExtraLargeScreenWidth || !canUseHelpSidePanel;

// 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 || !shouldHideSidePane || isLanguageUnsupported;
const shouldHideHelpButton = !canUseHelpSidePanel || !shouldHideSidePane || isLanguageUnsupported;
const shouldHideSidePaneBackdrop = shouldHideSidePane || isExtraLargeScreenWidth || shouldUseNarrowLayout;

return {shouldHideSidePane, isSidePaneHiddenOrLargeScreen, shouldHideHelpButton, shouldHideSidePaneBackdrop, sidePaneNVP};
Expand Down Expand Up @@ -82,25 +83,17 @@ function useSidePane() {
}, [shouldHideSidePane, shouldApplySidePaneOffset, sidePaneWidth]);

const openSidePane = useCallback(() => {
if (!sidePaneNVP) {
return;
}

setIsSidePaneTransitionEnded(false);
KeyboardUtils.dismiss();

triggerSidePane({
isOpen: true,
isOpenNarrowScreen: isExtraLargeScreenWidth ? undefined : true,
});
}, [isExtraLargeScreenWidth, sidePaneNVP]);
}, [isExtraLargeScreenWidth]);

const closeSidePane = useCallback(
(shouldUpdateNarrow = false) => {
if (!sidePaneNVP) {
return;
}

setIsSidePaneTransitionEnded(false);
const shouldOnlyUpdateNarrowLayout = !isExtraLargeScreenWidth || shouldUpdateNarrow;
triggerSidePane({
Expand All @@ -111,7 +104,7 @@ function useSidePane() {
// Focus the composer after closing the side pane
focusComposerWithDelay(ReportActionComposeFocusManager.composerRef.current, CONST.ANIMATED_TRANSITION + CONST.COMPOSER_FOCUS_DELAY)(true);
},
[isExtraLargeScreenWidth, sidePaneNVP],
[isExtraLargeScreenWidth],
);

return {
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);
}
Comment on lines +61 to +63

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this isn't used anywhere? If so let's remove it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a tracking issue to remove the beta when it's no longer needed anyway, not blocking on this.

@blazejkustra blazejkustra Apr 3, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I missed that one 🤦 I should've used this function as the selector of useOnyx. I'll refactor it for Stage 4


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,
};