def check_in_session(swimmer, wanted_session, allowed):
    """Check swimmer in session."""
    in_session = False
    if swimmer.find_session_substr(wanted_session):
        in_session = True
    if allowed and in_session is False:
        for allow in allowed:
            if swimmer.find_group(allow):
                in_session = True
    if in_session is False:
        if swimmer.no_session_ok:
            return True
        if swimmer.is_coach:
            return True
        return False
    return True
