It is completely legal. There are no restrictions on reporting, on who manages you, on payroll, on budgeting, on being in one department vs. another, on being hired for A but moved to B, etc. All of those "back office" matters are completely and solely under the employer's control.