      (if (= (:library:useLimitationOption attributes) "orsp") ;; TODO: change this so not hardcoded
        (library-utils/render-property library-schema attributes :library:orsp)
        (library-utils/render-consent-codes library-schema attributes))
-     (library-utils/render-library-row "Discoverability" (if-let [group (:library:discoverableByGroups attributes)] group ALL_USERS))])])
-
-
+     (library-utils/render-library-row "Discoverability"
+                                       (let [groups (get attributes :library:discoverableByGroups [])]
+                                         (if (empty? groups) ALL_USERS (first groups))))])])
 
 (defn- get-initial-attributes [workspace]
   (utils/map-values

                         :fontWeight (when this "bold")
                         :color (when-not (or this (contains? pages-seen index)) (:text-lighter style/colors))}}
            title])) pages)]
      [:div {:style {:paddingBottom "0.5rem"
                     :color (when-not (contains? pages-seen (count pages)) (:text-lighter style/colors))
                     :fontWeight (when (= page-num (count pages)) "bold")}}
       "Discoverability"]
      [:div {:style {:color (when-not (contains? pages-seen (+ 1 (count pages))) (:text-lighter style/colors))
                     :fontWeight (when (> page-num (count pages)) "bold")}}
       "Summary"]]))

(defn- find-required-attributes [library-schema]
  (->> (map :required (:oneOf library-schema))


(def ^:private ALL_USERS "All users")

(defn- ensure-sequence [input]
  ;;input may or maynot be a sequence, make it a sequence
  (cond (sequential? input) input
        (nil? input) []
        :else [input]))

(react/defc DiscoverabilityPage
  {:validate (constantly nil)
   :get-initial-state
   (fn [{:keys [props]}]
     {:library:discoverableByGroups (ensure-sequence (:library:discoverableByGroups props))})
   :get-attributes
   (fn [{:keys [state]}]
     (select-keys @state [:library:discoverableByGroups]))
   :set-groups
   (fn [{:keys [state]} new-val]
     (swap! state assoc :library:discoverableByGroups (if (= new-val ALL_USERS) [] [new-val])))
   :render
   (fn [{:keys [state props this]}]
     (let [{:keys [library:discoverableByGroups]} @state
           {:keys [:owner? :curator?]} props
           editable? (and curator? owner?)
           selected (if (empty? library:discoverableByGroups) ALL_USERS (first library:discoverableByGroups))]
       [:div {} "Dataset should be discoverable by:"
        (style/create-identity-select {:value selected
                                       :display "flex" :alignItems "center"
