def METHOD_NAME(
    subject: Subject,
    group: Group,
    group_action: GroupAction,
    group_member: str,
    db_session: SessionLocal,
):
    """Updates an existing group."""
    plugin = plugin_service.get_active_instance(
        db_session=db_session, project_id=subject.project.id, plugin_type="participant-group"
    )
    if not plugin:
        log.warning("Group not updated. No group plugin enabled.")
        return
    # we get the list of group members
    try:
        group_members = plugin.instance.list(email=group.email)
    except Exception as e:
        log.exception(e)
        return
    subject_type = get_table_name_by_class_instance(subject)
    # we add the member to the group if it's not a member
    if group_action == GroupAction.add_member and group_member not in group_members:
        try:
            plugin.instance.add(email=group.email, participants=[group_member])
        except Exception as e:
            log.exception(e)
            return
        if subject_type == "case":
            event_service.log_case_event(
                db_session=db_session,
                source=plugin.plugin.title,
                description=f"{group_member} added to case group ({group.email})",
                case_id=subject.id,
            )
        if subject_type == "incident":
            event_service.log_incident_event(
                db_session=db_session,
                source=plugin.plugin.title,
                description=f"{group_member} added to incident group ({group.email})",
                incident_id=subject.id,
            )
    # we remove the member from the group if it's a member
    if group_action == GroupAction.remove_member and group_member in group_members:
        try:
            plugin.instance.remove(email=group.email, participants=[group_member])
        except Exception as e:
            log.exception(e)
            return
        if subject_type == "case":
            event_service.log_case_event(
                db_session=db_session,
                source=plugin.plugin.title,
                description=f"{group_member} removed from case group ({group.email})",
                case_id=subject.id,
            )
        if subject_type == "incident":
            event_service.log_incident_event(
                db_session=db_session,
                source=plugin.plugin.title,
                description=f"{group_member} removed from incident group ({group.email})",
                incident_id=subject.id,
            )