def get_custom_field_value(member, name, default=None):
    """
    :param member: A member that has custom fields, each field has a name and a value. member = {custom_fields: [{name: X, enum_value: Y}, ...], ...}
    :param name: Name of a custom field that the member might have
    :param default: If the member does not have the custom field with the given name, or the fields value in None, we return the default value.
    :return: The value of the custom field name or the given default if the member doesn't have the field or the value is None
    """
    default_value = {"name": default}
    return next(
        (
            field["enum_value"]
            for field in member["custom_fields"]
            if field["name"] == name and field["enum_value"]
        ),
        default_value,
    )["name"]