Hello,
If Amazon Linux 2 or any other distribution doesn't include the php-tidy package for PHP8 (maybe Amazon will add it in the near future, maybe you can contact them about this missing package), we recommend using an external repository.
In the case of Amazon Linux 2, you can use Remi's repository (https://rpms.remirepo.net/). Please check the following documentation that installs PHP, including Tidy, on Amazon Linux 2:
https://medium.com/@kalyanshettynetra/install-php-tidy-package-on-amazon-linux-2-machine-4479e0f06ab0
UPDATE: https://www.phpdocx.com/documentation/cookbook/convert-html-to-word (Transforming HTML without Tidy section).
Also, please note that HTML methods included in phpdocx have the following option: forceNotTidy . Although using PHP Tidy is recommended, this option can be used when Tidy can't be installed. Using this option requires adding a correct HTML/CSS to be transformed, if PHP Tidy is not available, the HTML/CSS can't be cleaned/repaired automatically.
Regards.