A couple years back there was a lot of discussion on this CF topic, someone even coined "poopologists". I learned that any normal person can make changes that permanently ends constipation, but as soon as I feel like I have reached the perfect combination of diet, medication and lifestyle, it stops working. So it seems.
Everyone touched on a cause and cure. Water with a dose of electrolytes is important enough to make it routine. I wonder about our thirst response, the 50 years I was undiagnosed I was chronically dehydrated. I get my electrolytes drinking a combination of coconut water and Gatorade. The more water, the better.
My first move toward ending hard constipation was a significant increase in my enzymes. I now am close to the correct amount of enzymes for food, over doing enzymes usually results in a hard stool. Unfortunately I didn't keep increasing my enzymes once I ended the chronic hard constipation and dealt with DIOS for a few years. Too little has its price.
I have Parkinson's disease and take narcotics for chronic pain. I am aware that this discussion is under the Pregnancy heading and if a pregnancy is part of the equation, my interfering conditions are rumored to be similar. I take a few supplements and a stimulant laxative to make sure I have a regular gut. We need calcium and magnesium because of CF and I get electrolytes in the bargain by taking about half of any recommendations on the bottle of a high dose calcium/magnesium citrate. I take a product "Mag-O", the scientist in me says that it should not be any more effective but it works.
Understanding MiraLax is important because it's not well explained IMO. Lactulase and PEG or MiraLax are bulking laxatives. When mixed with food in the digestive process the result is most often a pliant stool. PEG for laxatives is a big molecule PEG 5000 has five thousand times the size and weight of a PEG formula for thickening cough syrup. Its ability to absorb water makes a heavy stool. The stimulation of the gut begins with the weight and volume sensed by food and fecal material.
If stools are hard and dense, don't forget about IBS. Irritable Bowel Syndrome by its nature grabs and squeezes the water out of a formerly pliant stool. Each spasm squeezes feces against the bowel wall making it adhere and stay in place.
I would suggest looking into a low FODMAP diet to limit inherent gas and the unwanted feeding of less than helpful bugs, the opposite of Probiotics. I take a daily probiotic but a problem exists according to recommended reading "The Gut". Unless you feed the probiotic bacteria, they won't thrive. Taking a daily probiotic is about half effective.
Good luck and Good Habits.
LL