Using the position the current user has in the company structure is an interesting idea and sure would be ideal implementation. This means however that this information needs to be available what is not always the case
When no objections we will implement the following:
When there is only a single INTERNAL_ORGANIZATIO company, then the header should not change and this company is automatically selected.
When there are more than a single company, a click-able accounting company name should be shown in the header.
Show the selected company in the user preferences, when not available use the system preferences, when not available use the oldest accounting company created, when nothing found show the accounting company setup screen where the partyid can be selected or created.
When the accounting company name in the header is clicked, show a popup with a list of accounting companies.
Check if the current user is part of an accounting company(partyRelationship), when yes, show that company and all accounting companies lower in the accounting company tree. A user can be part of more than a single company.
When the current user is not part of an accounting company, show all companies alphabetically with the role INTERNAL_ORGANIZATIO.
Let the user select the company and update the context and user preference.