In recent years, with the widespread use of non-linear loads power electronic devices associated with the penetration of various renewable energy sources, the distribution system is highly affected by harmonic distortion caused by these sources. Moreover, the inverter-based distributed generation units (DGs) (e.g., photovoltaic (PV) and wind turbine) that are integrated into the distribution systems, are considered as significant harmonic sources of severe harmful effects on the system power quality. To solve these issues, this paper proposes a harmonic mitigation method for improving the power quality problems in distribution systems. Specifically, the proposed optimal planning of the single tuned harmonic filters (STFs) in the presence of inverter-based DGs is developed by the recent Water Cycle Algorithm (WCA). The objectives of this planning problem aim to minimize the total harmonic distortion (THD), power loss, filter investment cost, and improvement of voltage profile considering different constraints to meet the IEEE 519 standard. Further, the impact of the inverter-based DGs on the system harmonics is studied. Two cases are considered to find the effect of the DGs harmonic spectrum on the system distortion and filter planning. The proposed method is tested on the IEEE 69-bus distribution system. The effectiveness of the proposed planning model is demonstrated where significant reductions in the harmonic distortion are accomplished.