Is setDockIconVisible broken on Monterey?

On Juce 7.0.2 we have a SystemTrayIconComponent (standalone App) that is supposed to show only in the system tray (not ever as a Dock Icon).
However every time it opens the app icon in the Dock shows… we try to set Process::setDockIconVisible (false) at various places in the code and at no time does the dock icon disappear…

Debugging we notice assert every time here… (with err = -50)


void Process::setDockIconVisible (bool isVisible)
{
    ProcessSerialNumber psn { 0, kCurrentProcess };

    OSStatus err = TransformProcessType (&psn, isVisible ? kProcessTransformToForegroundApplication
                                                         : kProcessTransformToUIElementApplication);
    jassert (err == 0);  <<<  err = -50 
    ignoreUnused (err);
}

I have replicated this issue with DemoRunner and found this issue occurs when the app is run from /Applications (not when run from Build folder)… Adding info.plist item Application is agent (UIElement) did the trick.