button.onClick.AddListener not working (solved)

I have script PoolGetter that is attached to a button object (let’s name it button A), where this button object is instantiated at runtime. When the button is clicked, it will instantiate a confirm panel with 2 extra buttons: yes button and no button, each contains an onclick.addlistener.

Currently when clicking button A, it successfully instantiates the confirm panel, but when clicking the yes button or no button, it does not trigger the functions. Any help would be appreciated.

Below is the PoolGetter code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class PoolGetter : MonoBehaviour{

    //Get other objects
    GameStatManager gameStatManager;
    public GameObject confirmPanel;
    Transform mainPos;

    //Get this
    Pool pool;

    //Local var
    string poolName;

    void Start(){

        //Get other objects
        gameStatManager = GameObject.Find("GameStatManager").GetComponent<GameStatManager>();
        mainPos = GameObject.Find("Interface").transform;

        //Get this
        pool = GetComponent<Pool>();
        this.GetComponent<Button>().onClick.AddListener(OnPoolClick);

        poolName = transform.Find("PoolName").GetComponent<Text>().text;
    }

    void OnPoolClick(){

        //Show confirm panel
        Instantiate(confirmPanel, mainPos);
        confirmPanel.transform.Find("AlertPanel/QuestionPanel").GetComponent<Text>().text = "Are you sure you want to join "+poolName+"?";
        confirmPanel.transform.Find("AlertPanel/ButtonContainer/YesButton").GetComponent<Button>().onClick.AddListener(() => OnYesClick());
        confirmPanel.transform.Find("AlertPanel/ButtonContainer/NoButton").GetComponent<Button>().onClick.AddListener(() => OnNoClick());
    }

    public void OnYesClick(){
        Debug.Log("Clicked yes");
        gameStatManager.SetCurrentPool(pool);
        Destroy(confirmPanel);
    }

    public void OnNoClick(){
        Debug.Log("Clicked no");
        Destroy(confirmPanel);
    }
}

Alright, I finally figured it out. Turns out I have to store the new prefab when instantiated it.
Now the below code works:

void OnPoolClick(){

    //Show confirm panel
    GameObject newPanel = Instantiate(confirmPanel, mainPos);
    newPanel.transform.Find("AlertPanel/QuestionPanel").GetComponent<Text>().text = "Are you sure you want to join "+poolName+"?";
    newPanel.transform.Find("AlertPanel/ButtonContainer/YesButton").GetComponent<Button>().onClick.AddListener(() => OnYesClick(newPanel));
    newPanel.transform.Find("AlertPanel/ButtonContainer/NoButton").GetComponent<Button>().onClick.AddListener(() => OnNoClick(newPanel));
}

public void OnYesClick(GameObject newPanel){
    Debug.Log("Clicked yes");
    gameStatManager.SetCurrentPool(pool);
    Destroy(newPanel);
}

public void OnNoClick(GameObject newPanel){
    Debug.Log("Clicked no");
    Destroy(newPanel);
}