diff --git a/src/components/PopoverMenu.tsx b/src/components/PopoverMenu.tsx
index 78b780c19844..d41c1a9aaa63 100644
--- a/src/components/PopoverMenu.tsx
+++ b/src/components/PopoverMenu.tsx
@@ -158,12 +158,19 @@ function PopoverMenu({
onPress={() => {
setCurrentMenuItems(previousMenuItems);
setFocusedIndex(-1);
- setEnteredSubMenuIndexes(enteredSubMenuIndexes.slice(0, -1));
+ setEnteredSubMenuIndexes((prevState) => prevState.slice(0, -1));
}}
/>
);
};
+ const renderHeaderText = () => {
+ if (!headerText || enteredSubMenuIndexes.length !== 0) {
+ return;
+ }
+ return {headerText};
+ };
+
useKeyboardShortcut(
CONST.KEYBOARD_SHORTCUTS.ENTER,
() => {
@@ -215,7 +222,7 @@ function PopoverMenu({
>
- {!!headerText && enteredSubMenuIndexes.length === 0 && {headerText}}
+ {renderHeaderText()}
{enteredSubMenuIndexes.length > 0 && renderBackButtonItem()}
{currentMenuItems.map((item, menuIndex) => (