Inverter-based resources and non-linear loads are causing issues with increased harmonics distortion in distribution networks. This limits the hosting capacity and makes it challenging to install new renewable energy sources. Generally, passive filters are essential for eliminating harmonics, which in turn improves the hosting capacity. This paper discusses the improvement of hosting capacity in distribution systems where harmonics are generated as a result of PV and nonlinear loads. We focus on discussing the design of passive filters for improving hosting capacity. Additionally, the focus is on reducing active power losses and minimizing reactive power capacity to enhance the efficiency of passive filters. In this process, an objective function is defined, and a Monte Carlo-based iterative simulation is designed. To demonstrate the validation of the proposed method, a comparative analysis of case studies was conducted.