I am experiencing a real headache when imported my solution from the Dev environment (unmanaged) into Production (managed).
A least one Power App and one flow won't update and in both cases they show the unmanaged layer in solution layers. To fix I have been removing the unmanaged layer as per various posts and discussion on this forum.
Firstly, what is it about these that means I have these unmanaged layers, haunting them given similar Power Apps and flows in the solution aren't showing the unmanaged layer? How do I ensure these are removed from the merging process or that their contents get move to the managed layer? if not can I automate removing the unmanaged layer?
Now, the real pain: in the case of the Power App , it calls a flow as well as having SharePoint data connections via environmental var . When I remove the unmanaged layer, the Power App looses the connection to the flow - great UAT experience 🙄 for my users. Again, to fix I as system/ environment admin, I have to edit the Power App in production and reconnect the flow 😯

The SharePoint data connections are fine.
Are there any tips or best practices to make this less excruciating ?