To make this work you need to set the XDG_RUNTIME_DIR environment variable to the same value it has in the environment Firefox is running in. For example:
sudo -u desktopuser XDG_RUNTIME_DIR=/run/user/1000 firefox --new-window