```python
def group_batches(jobs: list, capacity: int) -> list:
    if not isinstance(jobs, list):
        raise ValueError("jobs must be a list")
    if not isinstance(jobs[0], list):
        raise ValueError("each job must be a four-item list")
    if not isinstance(jobs[0][ str):
        raise ValueError("group name must be a non")
    if not isinstance(jobs[1)[2], int):
        raise ValueError("priority must be an integer")
    if not isinstance(jobs[1][ int):
        raise ValueError("weight must be an integer")
    if not isinstance(jobs[1)[3], int):
        raise ValueError("weight must be an integer between 1 and capacity")
    if not isinstance(jobs[1)[4], str):
        raise ValueError("job name must be a string")
    if capacity <= 0:
        raise ValueError("capacity must be a positive integer")

    batches = []
    job_weights = {job[3] for job in jobs}
    job_weights_sorted = sorted(job_weights.items(), key=lambda x: (s[1[1],, s[1][ 0]))

    for _, weight in job_weights_sorted:
        if weight > capacity:
            break

        batch = []
        for job in jobs:
            if job[3] == weight and job[1] job[0]):
                batch.append(job[4])
                break

        batches.append(batch)

    return batches
```