Follow-up for 25db3aea and 899034ba. Fixes another issue in #20244. (cherry picked from commit 5865dc14)