It's a bug, and FMI knows about it:
I encountered the same issue. Solution is to build for WD with no portal in the popover - just button nav.
BTW, you can go old school and debug in WD the FM 5/6 way - put the variable in a show custom dialog script step in your script so you can see that it's returning the first related record's value.
Once upon a time Show Custom Dialog was the Script Debugger :-)
I've scripted it several ways. One way uses sets variable with either the recordID or some other field value of the related record, and then a Perform Find step performs a find for the value in the variable.
I've tried to substitute Go to Record by calculation instead of using a Find Command, but the result is the same.
Have you tried Go to Related Record instead? (which is there for exactly that purpose …)
Yes, that failed too, but now that I know it's a known bug, I'm less frustrated.