This is wrong. At the Ruby level, the ENV var is one of the official toggles, see the Ruby official documentation about this here
This is wrong as DISCOURSE_YJIT_ENABLED only feeds GlobalSetting.yjit_enabled → config.yjit in config/application.rb. Rails uses that to enable YJIT if it isn’t already on. It does not disable an already-enabled YJIT. So when the env var is set, DISCOURSE_YJIT_ENABLED has nothing to do.
To further prove my point I wrote a plugin that returns if YJIT is enabled on my web process:
https://discourse-on-a-pi5.falco.dev/ruby-info
You are confused about the Rails level toggle, which is unnecessary as use the Ruby level toggle.