I think you just have to select the right ancestor element.
news.ycombinator.com##.athing:has(a[href="user?id=example"])
seems to work. news.ycombinator.com##.athing:has(a[href="user?id=example"])
seems to work.