Welcome to the forum.
Most common issue on the 4.0l SOHC for your symptoms is the PCV hose elbows, they crack on the under side and look great from above but cause rough idle and Lean codes
Good read here on that: PCV Elbow - Fix for a very common CEL!
Also Clean the MAF sensor, should be done every year or so, you do need to use electronic or MAF cleaner which doesn't leave a residue, but it is a simple spray it on and let it dry, so not at all hard to do.
The 1997 to 2004/5 4.0l SOHC engines also had a timing chain tensioner issue, not related to your problem, just a heads up
There are 3 tensioners, 2 can be changed without too much work, and they are the ones that tend to fail
When these started to fail the chain would get loose and beat on the guides, the guides would break and you would start to get a rattle in the engine.
Engine needed to be pulled out to change rear timing chain guides and chain, so not an easy fix