Is it possible to optimize the following boolean checks?
I came up with a different solution by utilizing Python's magic method for == which is __eq__(self, other).

I define it in the User class like so:

class User(object):
    def __init__(self, key):
        self.key = key
    def __eq__(self, other):
        return self.key == other.key if isinstance(other, User) else False


This allows you to do the obvious User(1) == User(2) testing but also this allows you to test membership in a collection using the in keyword:

User(1) in [User(1)] # This will return True
User(1) in [User(2)] # This will return False


We can then change the condition slightly to make the is_ok function like this:

def is_ok(user_dbs, self_db):
    count = len(user_dbs)
    if not self_db:
        return not count
    return count == 1 and self_db in user_dbs or count == 0


This has the advantage of being a bit more readable, and hence Pythonic. This might come in handy elsewhere as well.

Another minor point is that if you ever rename key to something else or change the structure of your User class, this code will still work (remember to update __eq__!), while most of the alternatives will break.