The snippets in the following article won’t work with tasks that require taking a note after being set: you’ll be left with a note where the task was.
I recently stumbled upon this article from systemcrafters, and quite liked the idea of being able to store DONE tasks into org-roam dailies. However, I already had a working system using org archives which held metadata about the task and kept hierarchy, and I wanted to avoid scrapping that (I also think it makes more sense to archive DONE tasks than to refile them) so I adapted the snippet from systemcrafters’ article to fit my needs.