How did I fix «Environment emulation nesting is not allowed» on sending invoice / shipment / creditmemo emails in 2.4.4 ≤ Magento < 2.4.7-beta2?

The solution

Step 1.1

Add the code:

Step 1.2

Replace the code:

with the code:

Step 2.1

Add the code:

Step 2.2

Replace the code:

with the code:

Step 3.1

Add the code:

Step 3.2

Replace the code:

with the code: