                                       name: member.name ?? "",
                                       isLead: member.isLead,
                                       isEditable: !member.isLead && editing,
-                                      isLastItem: index == self.team.members.count - 1,
+                                      isLastItem: index == self.team.count - 1,
                                       context: context)
       ])
     }
 
     cells.append([
       SettingsActionCellContext(
-        title: "Invite \(self.team.capacity - self.team.members.count) new team members",
+        title: "Invite \(self.eventTeamLimit - self.team.count) new team members",
         buttonStyle: .plain,
         context: TeamSettingsContext.invite)
     ])


      if let event = participant.currentEvent {
        self?.eventName = event.name
        let members = participant.team?.members.map {
          ($0.fbid, names[$0.fbid], imageURLs[$0.fbid], $0.fbid == participant.team?.creator)
        }
        self?.team = (members: members ?? [], capacity: event.teamLimit)
      }

      self?.configure()

  var cells: [[CellContext]] = []
  var completion: (() -> Void)?

  struct Member {
    let fbid: String?
    let name: String?
    let image: URL?
    let isLead: Bool
  }

  private var teamName: String = " "
  private var eventName: String = " "
  private var eventTeamLimit: Int = 0
  private var team: [Member] = []
  private var isLead: Bool = false

  var editing: Bool = false
