ENG-4213: Hofix for NPE

If/else logic was wrong.