Hey, welcome
Like @Stephen, I’m not entirely sure this is the right tool, but I trust you’ve thought it through sufficiently.
I would avoid this at all costs. There’s almost always another solution, even if you have to monkey patch a class. On monkey patching in Discourse see: Override existing Discourse methods in plugins.
In this case it seems as though there’s already code in the method you’re focusing on that does what you’re after: discourse/app/models/invite_redeemer.rb at main · discourse/discourse · GitHub
The issue is that the invites you’ve generated don’t have the right emailed_status_type
, so that condition isn’t passing. I think the solution here is to generate different invites in the first place. That’s where I would focus.