Yes! You were right. I have some other stuff in functions.php, so I tried putting your piece of code at the top of it and it worked. Then I narrowed it down by putting it after each function and test it to see when it actually broke. Turns out if I put it after my custom toolbar links, it doesn’t work. The hook looks like this (used this tutorial):
add_action('admin_bar_menu', 'custom_toolbar_link', 999);
I assume 999 is the priority, and it must be the source of the issue?