By the looks of the picture, with the chain in the highest gear ratio on the cassette cluster, that is where you want the chain to be when removing your rear wheel to make the flat repairs.
There should be a small toggle switch on the derailleur body, with an on-off setting. This is for the derailleur clutch. When removing the wheel for flat tire repairs, putting that clutch to the "off" position eases the clutch tension, allowing you to move the derailleur cage easier when lifting the tire off the frame. Don't forget to put the clutch setting back to "on" after repairs are made; this will prevent the chain from bouncing and scratching your chain stay when you hit a bump in the road. Removing the chain off the cassette with that clutch engaged can be tough and I suspect you did not release the clutch tension.
If you can't remove your display to flip your bike over & make repairs, you can always go with my "poor man's bike stand", consisting of a simple strap under your saddle. All you need is a good tree limb or something similiar to hold the weight of the bike.
View attachment 90855
Poor Man's EBike Stand......about a dollar twenty five at Harbor Freight.
View attachment 90856
Shimano XT derailleur. Note above the Shimano name you will see "On". There is a plastic grey toggle switch placed in the down position, to "Off". This is to relieve spring tension inside the derailleur clutch, allowing you to easier swing the derailleur cage when moving the wheel off the chain & frame. When repairs are done, place gray toggle clutch switch to the "On" position.....