We don't support converting branches to companies, we actually prevent changing the hierarchy via a blocking message in the code:

https://github.com/odoo/odoo/blob/19.0/odoo/addons/base/models/res_company.py#L341
def write(self, vals):
if 'parent_id' in vals:
raise UserError(self.env._("The company hierarchy cannot be changed."))
The only option is to use SQL to update the parent_id field and then call _parent_store_compute() to update the computed fields.

Note: Odoo does not support or recommend making changes to your Odoo database with SQL. Odoo Support cannot assist you resolving any issues that arise from making database changes with SQL. If you run into any issues, you will need to purchase a Success Pack so that a Consultant can bill all hours spent troubleshooting and repairing your database.
If you are prepared to
rigorously test a potential conversion and resolve any issues yourself, example code for a Server Action would be something like this:
# assuming the ID of your original company is 1 and the ID of the parent is 2
# this will make company 1 a branch under company 2
env.cr.execute("UPDATE res_company SET parent_id = 2 WHERE id = 1;")
env['res.company']._parent_store_compute()