Matt 18:17 doesn’t say that the whole church should treat either as an outcast. Consider the whole teaching. It has to do with conflicts between two individuals. Rather than allowing the differences to fester, there is a process to try to resolve the differences & if that process is unsuccessful, they should stop dealing with each other.
Consider John 10, specifically John 10:16.