How can I manipulate a TXT file generator so that it gives me the right values?

I created a family tree generator for characters.
When I add a character, I can add a relationship to the other registered characters.
My problem is that when I generate a txt of the selected character, I can’t get it to show me just the name of the relative and their relationship.
I needed him to return to me, for example, the list of Elliot’s relatives:
Jonh (Brother)
Kyle (Grandfather)
Joe (Father)
enter image description here
But this is my result
enter image description here

That’s my function

gerarArquivoBtn.addEventListener('click', function () {
        const selectPersonagem = document.getElementById('selecionarPersonagem');
        const personagemSelecionado = selectPersonagem.value;
    
        let dados;
        if (personagemSelecionado) {
            dados = pessoas
                .filter(p => p.parentesco.includes(personagemSelecionado))
                .map(p => {
                    const parentescoIndex = p.parentesco.indexOf('(');
                    const parentesco = parentescoIndex !== -1 ? p.parentesco.slice(parentescoIndex + 1, -1).trim() : ''; // Verifica se existe o caractere ( na string parentesco, se existir, pega a substring entre ( e ), remove os espaços em branco extras
                    return `${p.nome} (${parentesco})`;
                })
                .join('n');
        } else {
            dados = pessoas
                .map(p => {
                    const parentescoIndex = p.parentesco.indexOf('(');
                    const parentesco = parentescoIndex !== -1 ? p.parentesco.slice(parentescoIndex + 1, -1).trim() : ''; // Verifica se existe o caractere ( na string parentesco, se existir, pega a substring entre ( e ), remove os espaços em branco extras
                    return `${p.nome} (${parentesco})`;
                })
                .join('n');
        }
    
        const blob = new Blob([dados], { type: 'text/plain' });
        const url = URL.createObjectURL(blob);
        const a = document.createElement('a');
        a.href = url;
        a.download = 'arvore_genealogica.txt';
        document.body.appendChild(a);
        a.click();
        URL.revokeObjectURL(url);
        document.body.removeChild(a);
    });

I know it’s wrong… but I can’t fix it.

I tried to separate the information and tried to get just the relationship, but I couldn’t. I was probably going about it the wrong way, but I’d rather take the relationship type than cut a cord.
Some family relationships in Portuguese are compound words, so I believe that dealing with these words is very complicated.