Fix invite merging function