json.id user&.id
json.user do
  json.partial! "organizations/user_detail", user: user
end

json.team_names user.teams.where("teams.organization_id=?", organization.id).pluck(:nickname)
join_date =  if user.organization_users.find_by(:organization_id => organization.id).present?
               user.organization_users.find_by(:organization_id => organization.id).created_at.strftime("%Y-%m-%d")
             elsif user.members.joins(:project).find_by(project: organization.projects).present?
               user.members.joins(:project).find_by(project: organization.projects).created_on.strftime("%Y-%m-%d")
             else
               user.created_on.strftime("%Y-%m-%d")
             end
json.created_at join_date
