I'm not really sure what the issue is. If the orders table has product_id 1 and is returned in the query it's already finalized right. The group by is not gonna sort it by the the number of grouped items. You need a complete different query for that. I don't think that's possible with whereHas.
Also whereHas is just checking if the items are there, it's not returning them. If you want that you need to use with instead.
Can you maybe explain what you want to achieve and what relations you have?