Refs #16751; optimize getting versions to avoid making a catalog query if versionId is empty