Are you prefixing this auto generated query with set join_collapse_limit = 30, or are you changing the default and reloading config? That is, can you impact ONLY this query with these config changes? I wouldn't assume so, so any hack/query hint like turning off hashjoins (which seem to be chosen instead of nested loop because of bad estimates for this plan) will likely have serious impact on other queries.
I know you don't have the flexibility to change the query to be one that follows best practices, but it is a bit disappointing that your ORM generates that OR condition instead of something like brs.branch_id IN (query1 union all query2). The join to branch_invoices also must function as inner join rather than left, but I am not sure if declaring a join type as left impacts the performance significantly.
When performance matters, there's nothing quite like being able to customize the query directly.