With almost all cichlids, keeping more than 1 pair in a puddle just doesn't work, no matter the species, and a 40 gal in basically a puddle, or no more than a rut in the road .
You could probably house a pair in a 40 gal with non-cichlids, that are large enough to not be swallowed.
An example
About 3 years ago, I received a dozen 2" Andinoacara coerleopunctatus, they normally mature about 4-5", and males sometimes top off at 7".
I put them in a 180 gal tank.
They did well for a little over a year.
At that point the alpha male matured, and started killing off all other males, and a few unreceptive females.
He allowed 3 females to live in that size tank with him, for the next couple years, and spawned with each one regularly.
When I received the Andinoacara, they also came with local tetras, and a local Panamanian pleco.
The alpha has always ignored all the non-cichlids, because they posed no territorial threat.
I do a lot of collecting myself here in Panama, and for every cichlid I find, it is usually surrounded by at least 10 times more tetras.
One of the most common mistakes cichlids keepers make is thinking they can keep large numbers of cichlids together in inadequate size tanks.