I would humbly suggest you're overthinking the solution to this problem. Surely, it would make more sense to set the keyboard shortcut you want for toggling DND in System Preferences > Keyboard > Shortcuts and let macOS handle it?
I would first follow tjlouma's suggestion to try an alternate shortcut. If that makes no difference, it could be that in your full macro a pause is needed between the application launch and the activation of Do Not Disturb. The pause doesn't necessarily need to be long, maybe just a few seconds or until the app that was launched has completed its launch process.