You can't dynamically set openAppWhenRun. You need to create a new AppIntent with openAppWhenRun = true, and call it from you existing AppIntent using return .result(openIntent: NewAppletName()). The Dive into App Intents video has an example of this.
https://developer.apple.com/videos/play/wwdc2022/10032/ at 17:19.