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:
![RhettZufelt_0-1673571476625.png RhettZufelt_0-1673571476625.png](https://community.esri.com/t5/image/serverpage/image-id/60356iDA32582BD157C263/image-size/medium?v=v2&px=400)
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_