I had a shrimp with my betta in a one gallon.. he nipped at the shrimp a bit at first, n he'd hide in the minipineapple alot, but then they were fine, they'd even sit at the bottom of the bowl next to eachother alot just chillin the shrimp would run his antenae over him alot it was weird... theeeen my shrimp died three days later because I didn't know they needed filtration or airation

then the betta ate him after he died :/
Conclusion: It's fine if there is air coming in or filter, they won't eat eachother, at least mine didn't and it's always nice to have a hiding personal space to go to for everybody in there.