We normally allow project leads and certain users the ability to delete issues in Jira but recently we have had an outbreak of users deleting issues with time logged to them and that is a big issue so in the short term I have disabled the ability to delete cards for everyone.
Long term possible solution is:
- No one has the ability to delete.
- We introduces a new status, To be Deleted, we allow project leads to move cards to this status.
- When a card is moved to the To be Deleted Status automation runs a check on it and actions it depending on what it finds (picture below of the automation).
- If it has timespent automation moves the card back to In Progress and emails the assignee letting them know that the card has timespent on it so we are unable to delete, contact the Jira team if you need more help.
- If it has no timespent the automation deletes it.

The issue is, what if this is a Story and the Subtask has time?
So first thought was just use sigma timespent and that solves the issue, but after checking the automation possibilities and researching online I am finding that isn't possible.
I also tried to have it check the subtask for matches with time, but this also doesn't seem possible.
So the question would be, is there a way to have this automation also verify the Subtask doesn't have time as well before deleting?