Email Issues- Can't call method "Name" on an undefined value

Running RT 5.0.2

All was running well until trying to clean up our huge Users table. Ran the command from the wiki- deleted several thousands of users:

rt-shredder --plugin "Users=no_tickets,1;status,any;replace_relations,Nobody;limit,xxx" --sqldump /{somepath}/shredder-restore-users.sql --force

Was not aware of any issues until we saw that numerous tickets were created over and over and over again for the same email.

Postfix queue showed the below:

RT server error. The RT server which handled your email did not behave as expected. It said: Can't call method "Name" on an undefined value at /opt/rt5/sbin/../lib/RT/Interface/ line 1389. Stack: [/opt/rt5/sbin/../lib/RT/Interface/] [/opt/rt5/sbin/../lib/RT/Interface/Web/] [/opt/rt5/share/html/REST/1.0/NoAuth/mail-gateway:82]

This occurs on all incoming emails, for both new tickets and replies.

When this happens, the ticket is created/updated appropriately but postfix shows this message.

Then the same ticket keeps getting created over and over again.

I’ve gone and restored the Users table using a backup and I’ve run through the rt-validator but am still having this issue.

Does anyone have any ideas what we can do to fix this?

Thank you.

The code in the above error for me in lib/RT/Interface/ was:

   level   => $log_sql_statements,
   message => ($HTML::Mason::Commands::session{'CurrentUser'}->Name //

At one point while shredding users I enabled
"Set( $StatementLog, 'debug' );"

After turning this off I no longer seem to have this issue.