Hi and welcome tot he forum! I am glad that I can help you.
You want to know whether being constipated can cause depression.
Constipation is a condition where individuals experience difficulties passing the stool. This condition may appear as a result of ignorance of the need to defecate due to the circumstances, dehydration, diet rich with bananas or chocolate, and physical blockage of the colon due to cancer or polyps. Constipation itself doesn't cause depression, but individuals who experience depression may be ignorant towards their needs including eating, defecating, socializing with people, etc.
Given the data that you described, it is not likely that constipation caused the depression that you experience. You may consider having a contrast x-ray exam of your abdomen to rule out any condition that may cause blockage in the passing of the feces, such as polyps or cancer. You may also need to have a colonoscopy as well for further diagnosis.
Please keep in mind that I provide medical information only. I am not able to diagnose medical conditions online. Please contact your doctor for further advice and information about diagnosis and treatment options.