formula_installer: check for recommended/optional.

build.without? seemingly always returns true for requirements that are
neither recommended nor optional so check these before deciding not to
install a default formula.

Closes #31511.