Niagara PS is not visible in render when stencil layer is on

I am trying to render a scene and using stencil layers for it. But whenever stencil layers are added in Movie Render Queue, the Niagara PS is not visible in the render. Then rechecked if I have added the PS to Layers and no Issues there . Am I doing something wrong here Help me here please

Hello, Maybe I can help you.Make the " Render Custom Depth Pass"option is on in your Niagara System.

Thanks this fixed it for me. Dont forget to set it in the details panel as well, if your using plugins or anything like that ( like uds )