Hi Ong Yong Siang,
Welcome to community.
Per my search, the error message "You have to delete all the items in this folder before you can delete the folder" may be related to the site/library which is on hold.
For troubleshooting, you may go to Site Contents page
(https://yourtenant.sharepoint.com/sites/sitename/_layouts/15/viewlsts.aspx?view=14) and see if there is a library called Preservation hold library.
In the meantime, to check if the site is on hold and if the site is protected by any DLP, I recommend you contact your Microsoft 365 admin and verify it from Microsoft 365 Compliance center.
For reference: How do I find my Microsoft 365 admin
1.Let the admin go to Microsoft 365 Compliance center
2.Go to Policies > Retention > Retention policies, see if there is any retention policy is applied to the site.
Go to Policies > Data loss prevention > Policies, see if there is any DLP policy is applied to the site.
Go to eDiscovery > Core, see if any holds are created.
If you can find any, turn them off. Then go back to the site and try to delete the folder and check the outcome.
Note: it may need some time to take effect after disabling the policy. You may need to wait some time and check the outcome.
More detailed information about Retention policy, holds and data loss prevention, you may refer to these articles:
Create and configure retention policies
Data loss prevention reference
Feel free to post back when you have any update.
Have a nice day and stay safe.
Best Regards,
Tina