onClick.AddListener doesn't get assigned to button.

Nothing happens when I try to assign this method to a new button. Can anyone explain why?
This worked when I used to do it.

Thanks!

GameObject flag = Instantiate(rivalFlag, rivalBox.transform.position, Quaternion.identity);
flag.transform.SetParent(rivalBox.transform);
flag.GetComponent<Button>().onClick.AddListener(() => OpenCountryPanel(rival));

If it would be always that simple ^^

        Button b = flag.GetComponent<Button>();
        b.onClick.AddListener(delegate { OpenCountryPanel(rival); });

Greetings,

Max