Keep the incidence angle fixed
At normal incidence in air, a plane grating follows d sin β = mλ. Here d is the groove spacing, β is the angle from the normal and m is the integer order. Wavelengths with the same product mλ have the same diffraction direction.
Where 400 nm meets 800 nm
Take a groove spacing of 1.6 µm. First-order light at 800 nm and second-order light at 400 nm both give sin β = 0.5. Both emerge at 30° on the same side of the normal.
What a detector sees
A pixel at that angle can receive both wavelengths if the source, optics and detector pass them. Their relative signals depend on the grating efficiency and detector response. An order-sorting filter can reject the unwanted wavelength before detection.