def get_instances_joined(game, player):
  """ Return the instance ids of instance that player has joined.

  Args:
    game: The parent Game database model to query for instances.
    player: The email address of the player to look for in instances.

  Returns:
    An empty list if game is None. Else, returns a list of the instance
    ids of all instances with game as their parent that have player in
    their joined list.
  """
  if game is None:
    return []
  query = game.get_joined_instance_keys_query(player)
  return [key.name() for key in query]