def get_viewconf_status(files):
    """
    Determine the Higlass viewconf's status based on the files used to compose it.

    Args:
        files(list)             : A list of file objects that contain a status.

    Returns:
        A string.
    """

    # The viewconf will be in "released to lab" status if any file:
    # - Lacks a status
    # - Has one of the "released to lab" statuses
    # - Doesn't have a "released" or "released to project" status
    released_to_lab = [
        "uploading",
        "uploaded",
        "upload failed",
        "deleted",
        "replaced",
        "revoked",
        # "archived",
        "pre-release",
        "to be uploaded by workflow"
    ]
    if any([ f["accession"] for f in files if f.get("status", None) in released_to_lab ]):
        return "released to lab"

    # If any file is in "released to project" the viewconf will also have that status.
    released_to_project = [
        "released to project",
        "archived to project",
    ]
    if any([ f["accession"] for f in files if f["status"] in released_to_project]):
        return "released to project"

    # All files are "released" so the viewconf is also released.
    return "released"