Adding a new variable to account menu for twig rendering I am trying to add a variable to render in the menu-account.html.twig file.

Here is my preprocess function in my .theme file.

function HOOK_preprocess_menu__account(&amp;$variables) {
    $variables['account_name'] = Drupal::currentUser()-&gt;getAccountName();
}


HOOK is replaced with my theme name

And in my twig file I have this snippet:

&lt;div class="welcome-message"&gt;
    Welcome, {{ account_name }}!
&lt;/div&gt;


So I can edit pre-existing variables but I cannot seem to add a new one.

I was reading that new variables cannot be added in a preprocess function and that the HOOK_theme_registry_alter should be used.

Here is what I attempted and by using xDebug I can tell that it is getting looked at when flushing caches.

function HOOK_theme_registry_alter(&amp;$theme_registry) {
    $theme_registry['menu']['variables']['account_name'] = [];
}


Does anyone know the steps to get a new variable to be rendered in the menu twig file. This my first time using the theme registry hook so I might be doing something wrong there as well.

Thanks,

EDIT: "menu--account.html.twig" was named correctly in my code but mistyped in my question. Thank you to GiorgosK for pointing this out.
In your THEMENAME.theme

function THEMENAME_preprocess_menu__account(&amp;$variables) {
  $variables['account_name'] = Drupal::currentUser()-&gt;getAccountName();
}


And in your menu--account.html.twig 

&lt;div class="welcome-message"&gt;
  Welcome, {{ account_name }}!
&lt;/div&gt;


Just tested and it works, so basically what you posted should work but probably you mistyped the twig file name which needs two dashes (--)