BSS138 mosfet not for level shifting
Yes, it will work fine. The BSS138 needs about 2.5V Vgs to be sure of reaching 20mA. I get that from the Vgs(th) voltage of 1.5V maximum (1.3V typical) to get 1mA. You need 20mA (1V across 50 ohms) so refer to Figure 5 and adjust for possible unit to unit variations and add some safety factor.  The resistor needs 1V, so that's 3.5V. 

The LMV342 output, even with a 10K load to 2.5V, will swing to within 40mV of the +5 supply over the entire temperature range, so you have almost 1.5V to spare. 

The other worry is that the capacitive load may cause the op-amp to oscillate. In this case the capacitive load appears like around 40pF (maybe a bit more because of small Miller effect due to changes in the LED Vf with current) with 50 ohms series with some of it. Figure 30 indicates the op-amp with virtually no resistive load can handle 100pF without going unstable, so you're okay, but not a lot of margin. 



By the way, your premise that the BSS138 is primarily used for level shifting is not correct. It's a general purpose small logic level MOSFET, used in a great many applications. Here are the data sheet suggestions: 



Your application does fall outside of that range of applications because the MOSFET is used in a linear mode rather than switching.