I made up this circuit.
I was trying to get a voltage comparator with Hysteresis so that when a fast object passed in front of the photodiode the comparator would detect the small voltage drop and give a signal to an Arduino board.
In the datasheet, is the topic 7.7 "INPUT VOLTAGE RANGE" the reason it won't operate from 4.1 to 5V? In other words, it's range is only 0 to 3.5V if Vs=5V?
Alas you chose the wrong configuration which heavily loaded the voltage you were trying to sense.
You want to observe the voltage at the junction of the photodiode and 1M resistor? The you need an impedance much higher than 1M (not 200 ohms!).
You need a true rail-to-rail device for this, be it a comparator or an opamp, if you want to work right up against the +ve rail.
Make life easy and work down near ground - far more devices go to the -ve rail than to the +ve rail. In particular the LM358 should work close to its negative rail.
So redo the divider: photodiode to ground, 1M to 5V.
The way to wire this is inverting input sensing the photodiode, non-inverting input to the voltage reference (which would be 0.9V with things the other way up), adding hysteresis in that part of the circuit where it doesn't load the diode divider.