I’ve run into this issue quite a few times as well. What usually helps is wrapping both the text and the underline into a single Auto Layout frame, then setting the underline to Fill container. That way, it expands fully under the text as it grows.
Make sure the text is set to Hug contents horizontally.
Hope it helps!
Product designer @ NETWORG | Designing Model-driven Power Apps in Figma | Power Apps DesignKit (Model-driven)