The prior usage of a ternary expression caused the code to be formatted in a weird way, so this commit replaces the ternary with an `if` statement. PR Close #39961
The prior usage of a ternary expression caused the code to be formatted in a weird way, so this commit replaces the ternary with an `if` statement. PR Close #39961