I know a solution is using 2 diodes but issue is diode voltage drop as i say project is battery operated so unnecessary voltage drop for battery is not affordable
Circuit is below
You need LDO with very low dropout to make it work with normal li-ion/ lipo battery.
May I suggest you to use Esp32 board with built in battery management. It resolves your problem and few others eventually, battery protection and charging.
There is at least one specific chip/board that does that but I can't find a link. Some boards will auto select power but you need to look at the Espressif documentation about power to know for sure.
I will bet your 4.2vdc battery is really a 18650 Lithium, which means it's really a 3.7vdc battery, and not strong enough. If the VIN pin has an LDO attached, then the usual approach is to use two 18650s in series, and the LDO will drop the 7.4vdc to 5vdc.
A google search of
chip for managing two power sources
gives the following high level result (AI)
A Power Management Integrated Circuit (PMIC) is a chip designed to manage two or more power sources in a device. PMICs are commonly used in battery-operated devices and embedded systems to efficiently manage voltage regulation, power switching, and monitoring, often consolidating these functions onto a single chip to reduce component count and board space.
If you plan on using the ESP32 with WiFi, then you won't find an LDO that will work unless you test many different ICs and find one that works under load.
in my POV 1.4V dropout mean if we want to get 3.3v we have to apply at least 4.7Vbut i don't know if input voltage is below the fixed output voltage (3.3V) .let say 3v ii think it would give 3v at output not 1.6V.If the voltage is above 4.7V like 5v,10,v,16v it will cut it to 3.3V if voltage is below 4.7V it give will output same as it get in input