Many otherwise open-source chat apps are "open-core," they tie certain features to a subscription. Can be things like chat history, voice calls, video calls, but a very popular one is SSO and AD/LDAP integration.
Mattermost's licensing is a little confusing, but from what I understand, you're only really super-restricted if you use the prebuilt binaries (which have a different license than the source code).
IIRC if you build it yourself it's pretty much all AGPL, with few limitations.
Wait, what? There are open-source chat apps that you have to pay to host yourself? How does that work? Or did I misunderstand?