                            :project project}))]]
     (assoc user ::follow-count (count (get followings user)))))
 
-(defn invitees
-  "Filters users to invite and returns only fields needed by invitation API"
-  [users]
-  (->> users
-       (filter #(and (:email %)
-                     (:checked %)))
-       (map #(select-keys % [:email :login :id]))
-       (vec)))
+(defn invitees [users-by-login]
+  (->> users-by-login
+       vals
+       (filter (fn [user]
+                 (and (:selected user)
+                      (:email user))))))
 
 (defn invite-teammates-modal [{:keys [selected-org close-fn]} owner]
   (let [select-user! (fn [{:keys [login] :as user}]

        (when-not (:vcs-users selected-org)
          (api/get-org-members (:name selected-org) (:vcs_type selected-org) (om/get-shared owner [:comms :api]))))

      om/IInitState
      (init-state [_]
        {:selected-members #{}
         :show-modal? false})

      om/IWillReceiveProps
      (will-receive-props [_ {new-vcs-users :vcs-users}]
        (let [{old-vcs-users :vcs-users} (om/get-props owner)]
          (when (not= new-vcs-users old-vcs-users)
            (om/set-state! :org-members-by-login (into {}
                                                       (map (fn [{:keys [email login]}]
                                                              [login {:email email
                                                                      :selected (utils/valid-email? email)}])
                                                            new-vcs-users))))))
      
      om/IRenderState
      (render-state [_ {:keys [show-modal? org-members-by-login] :as state}]

                               "Invite Teammates")
                             (when show-modal?
                               (om/build invite-teammates-modal {:selected-org (select-keys selected-org [:name :vcs_type :vcs-users])
                                                                 :close-fn #(om/set-state! owner :show-modal? false)}))]}
                (if-let [users (:users selected-org)]
                  (table (add-follow-counts users (:projects selected-org)))
                  (html [:div.loading-spinner common/spinner])))
