I wonder if you could store the energy as pressure instead of electricity in batteries.
From what I gather[1], the biggest energy draw in reverse osmosis is pressurizing the water to force it through the RO filters. So, while the sun is shining, fill a tank halfway with salty water, then use solar energy to run pumps to pressurize air above the water. When the sun isn't shining, you now have pressurized water you can let through the RO filters.
Compared to a regular RO plant, this requires high-pressure storage tanks and additional pumps. I'm unsure whether that costs less than batteries or not.
Another part of the analysis is that, if you do build the batteries, they can earn extra money with a side gig stabilizing the grid. Occasionally, when grid conditions get very gnarly, you could shut down the RO plant for a few hours and make a quick buck selling your battery power on the market.
Alternatively, you could pump the water uphill during the day and let gravity supply the energy to force it through the RO filters at night. This means you'll have to build a special reservoir for pre-treated salty water somewhere, though, and you need a lot of pressure, so it would need to be at a high elevation.
---
[1] Source (kind of old): https://www.oas.org/dsd/publications/unit/oea59e/ch20.htm