The G Suite API (unlike Microsoft) unfortunately does not allow updating of messages. Therefore, to insert the scan results HTML at the top of the email, we delete the original email and create an identical new message, with the scan results inserted at the top.
By default, we move the original messages to the trash, but there is a OnINBOX setting that users can turn on that will permanently delete these instead, which will hide any prompt by Google that there are deleted messages in the chain.