How to apply security groups when selecting PDF templates during printing

Security groups work correctly when viewing PDF templates. Team A does not see team B templates. However, when printing to PDF, the select template menu shows all templates as seen on the attached screenshot.

Is there a way to fix this ?

image

Question: The team B could download team A pdf templates? or they are getting an error?

If I print to PDF an invoice using Team B user, the pdf template selection pop up should only show the Team B template. The problem is that it shows both Team A and B templates.

Might need to modify the code, or add custom code, a great question for @eggsurplus

Add one user condition in the query to display only logged user PDF Templates in Module Print as PDF Option as shown in below screenshot because Print as PDF displays all templates without considering Roles & Security Groups.

File Path : modules/AOS_PDF_Templates/formLetter.php

See Screenshot: Screenshot by Lightshot