How can I get the page url slug when ‘post_name’ returns an id?

Try this :

$menu = get_term( $locations[$theme_location], 'nav_menu' );
$menu_items = wp_get_nav_menu_items($menu->term_id);

foreach( $menu_items as $menu_item ) {
    $link = $menu_item->url;
    $title = $menu_item->title;
    $slug = basename($menu_item->url);
}

Pass the whole permalink to the basename function, which will automatically process the URL and give us only the slug.