Renewable energy sources generated locally are becoming increasingly popular in order to achieve carbon neutrality in the near future. Some of these sources are being used in neighbourhood (local, or energy communities) grids to achieve high levels of self-sufficiency. However, the objectives of the local grid and the distribution grid to which it is connected are different and can sometimes conflict with each other. Although the distribution grid allows access to all variable resources, in certain circumstances, such as when its infrastructure is overloaded, redispatch measures need to be implemented. The complexity and uncertainties associated with current and future energy systems make this a challenging bi-level multi-criteria optimisation problem, with the distribution grid representing the upper level and the neighbourhood grid representing the lower level. Solving these problems numerically is not an easy task. However, there are new opportunities to solve these problems with less computational costs if we decompose the flexibility in the lower lever. Therefore, this paper presents a mathematical approach to optimise grid management systems by aggregating flexibility from neighbourhood grids. This mathematical approach can be implemented with centralised or decentralised algorithms to solve congestion problems in distribution grids.