Here’s a nice hack: In add_menu_page, pass a non-existent capability (and you can leave off the function):
add_menu_page( "Myplugin", "Myplugin", "nosuchcapability", "Myplugin");
The automatically-generated submenu is blocked by the capability check.
Try this
add_menu_page( $page_title, $menu_title, $capability, $menu_slug, null, $icon_url );
add_submenu_page( $same_as_add_menu_page_slug, $page_title, $menu_title, $capability, $same_as_add_menu_page_slug, $function );
add_menu_page has null value as the function.
Also, only the first add_sub_menu menu-slug needs to be the same as the add_menu_page.