It's a confusing situation. Ranitidine can decompose and create NDMA, but there are two separate issues.
One, are some ranitidine pills contaminated with too much NDMA? This may be limited to specific brands and lots, and it should be fixable by improving the manufacturing method.
Two, does ranitidine spontaneously decompose IN THE BODY to release NDMA? This is iffy, with only one tiny study suggesting it might be the case, and needs more research.
Related: How much NDMA do we get in our diets anyway, and is the amount from ranitidine significant? Again, we've got conflicting data at the moment.
Also, the recalls are currently voluntary, not FDA-mandated or FDA-approved. So the fact that a particular manufacturer has not done a recall may be meaningless.
Famotidine (Pepcid) looks like the closest probably-safe substitute. It's a histamine H2 receptor antagonist like ranitidine, it has fewer drug interactions, and the chemical structure is different enough that there's no NDMA issue.