theming – Adding more variables to menu for use in menu.html.twig

I’m attempting to give menus more variables to work with besides the default menu_name,items, and attributes. This is because making a variable in the preprocess menu hook does not allow it to be accessible in the menu.html.twig template.

My ultimate goal is to be able to add menu items that contain the user id in the path.

I believe I need to add the var to menu by using hook_theme_registry_alter and follow the format of https://api.drupal.org/api/drupal/core%21includes%21theme.inc/function/drupal_common_theme/8.2.x

So I attempted to add a variable to menu in my .theme file like so

function mytheme_theme_registry_alter(&$theme_registry){
    $theme_registry('menu')('variables')('test_var') = 'testing theme registry alter';
}

But when I do so nothing appears when I alter menu.html.twig like so

<nav {{ attributes.addClass(navClasses) }} aria-label="MyWPT Menu Mobile" role="navigation" style="display:none;">
    {{ menus.menu_links(items, attributes, 0) }}
{#     {% macro menu_links(items, attributes, menu_level) %} #}
    {% macro menu_links(items, attributes, menu_level) %}
    {% import _self as menus %}
    {% if items %}
    {% if menu_level == 0 %}
    <ul class="vertical menu" data-drilldown>
        {% else %}
        <ul class="vertical menu">
            {% endif %}
            {% for item in items %}
                {% if item.below %}
                    <li class="is-dropdown-submenu-parents">
                {% else %}
                    <li{{ item.attributes }}>
                {% endif %}
                {{ link(item.title, item.url) }}
                {% if item.below %}
                    {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
                {% endif %}
                </li>
            {% endfor %}

            <li><a href="/">{{ test_var }}</a></li>
        </ul>
        {% endif %}
        {% endmacro %}

How would I add more menu variables for use in menu.html.twig ?

UPDATE: I also tried {{menus.test_var}} but that just broke the page

UPDATE 2: Using {{ kint() }} the test_var did not appear anywhere