Dividends are not included in a positions P&L calculation. However, if the dividend was actually designated as a Return of Capital distribution, then this would reduce the cost basis of the shares owned and affect the realized/unrealized P&L of the position.
More information on Return of Capital (ROC) distributions can be found in the IBKR Knowledge Base.
It is important to note that the trading platforms normally will not recognize the difference between an ordinary dividend and a return of capital, and therefore will not update the adjusted cost basis P&L amounts for positions that distributed a return of capital. Clients can manually update the displayed average price information in TWS by clicking the Account menu followed by Account Window, then right-click on the position in question and select Adjust Average Price.
For the accurate cost basis information, clients should reference the Open Positions section of the activity statement within Client Portal under Performance & Reports menu followed by Statements under Reports.