DEV: simplify logic when selecting an undefined value (PR #14225)

GitHub