I know that if you use the first one I supplied above that just returns the URL, you can add that as a popup expression, then add the expression in the fields list of the popup. This will give you a dynamic link that can use variable substitution to create the URL.
My example for testing (data I have), but still just returning the URL itself, not <a href/>:
var link = 'https://mygisorg.maps.arcgis.com/apps/webappviewer/index.html'
var field= $feature.Notes
var newlink = link + field
return newlink
with the value of Notes field being the id (the rest of the URL) so they are concatenated to form final URL.
When added as a field in the popup, looks like:
And when I click on the "View", it opens the dynamically created URL in new window.
But, have not figured out a way, or if it is possible to have the returned link say what you want. Might be stuck with "View", but at least you can 'build' the URL dynamically.
R_