If you look at the examples given in the Naked Variable documentation you will see there are limits to how complex a variable reference can be before you need to use one of the <> macros instead.
Also instead of using Story Variables to store the index values of your outer & inner for loops, you can use Temporary variables and pass the outer index as a argument to your <<display_subitems>> widget.
The following is a variation of your own code, it is written using TWEE Notation.
Ah! Thanks for pointing out the Naked Variable limitations. That handled the variable display part. Passing arguments to the widget makes it cleaner as well.
The subitems link text wasn’t showing, but after setting it to a temp variable, it worked.
That would be because the expression wasn’t being passed to the <<link>> macro properly. The <<link>> macro wants discreet arguments, so if you need to pass a lengthy/complex expression to it, then you either need to use a temporary variable or a backquote expression.
You did the former, so here’s an example of the latter: