Confusion can be caused by a variety of problems. This website lists 80 causes. https://www.healthline.com/symptom/confusion
The ones I would focus on are numbers: 1, 7, 27, 28 and 62.
#1 Hypoglycemia (low blood sugar). Many people develop a type of hypoglycemia after bariatric surgery called reactive hypoglycemia. https://www.ridgeviewmedical.org/services/bariatric-weight-loss/enewsletter-articles/reactive-hypoglycemia-postgastric-bypass
This can also occur if you were diabetic prior to surgery and did not reduce your prescription medicine after surgery.
#7 Low blood pressure. If you had high blood pressure prior to surgery and were taking prescription medicine for that condition. This may be an indicator that you may need to come off some of that medicine.
# 27 Hypokalemia (low potassium levels). Make sure you are taking vitamin/mineral supplements for potassium.
# 28 Hyponatremia (low blood sodium). Make sure you are getting enough electrolytes.
# 62 Beriberi (B1 deficiency). I would also lump B12 deficiency into this one. After Gastric Sleeve surgery, my surgeon recommended 100 mg. Thiamine (vitamin B1) weekly and 500 to 1000 micrograms sublingual B12 weekly. While you were in the hospital, you were probably given a shot of B12 which is good for one month. Since you are 4 weeks post-op that is probably wearing off and you need to begin taking B12 weekly.
I am not a doctor, so take everything I say with a grain of salt. But those are the areas I would explore.