Hey there @kauthon-retool, and welcome to the forum!
You can refer to this similar post.
You can use the js find function. So for example, in your invoices table, yo uselect your branchesid column, and within the mapped value field you can write something like {{ branchesTable.data.find (x => x.branchesid === item).branchesname }}
This is kind of a lookup. My recommendation would be to use the query as datasource, so instead of branchesTable.data, you would use query1.data (remember to format it as array, otherwise find function won't work). Another thing to bear in mind is that if your dataset does not contain any of the branchesid in your invoices table column, then it will also throw an error as find is expecting to find a match.