Processes in thermal energy storages (TES) based on granular phase change materials (PCM) are numerically studied. The influence of the sidewall shape on the efficiency of TES is studied in the case of plane-parallel flows of a gaseous heat transfer fluid (HTF). The TES shape affects the HTF flow, and this affects the transfer, accumulation, and recovery of heat in TES. By using a novel numerical model, the influence of narrowing and expanding sidewalls on charging and discharging processes in TES with rectangular cross sections are studied under boundary conditions of two types: a known mass flow rate of the gas at the TES inlet and a known gas pressure drop at the open boundaries of the TES for various PCM melting points. Different efficiency criteria are used to estimate the preferred shape of TES. For charging processes, the preference criteria considered are the maximum instantaneous storage efficiency, the maximum cumulative storage efficiency, and the minimum time taken to fully charge the TES. For discharging processes, the considered preference criteria are the maximum energy recovery efficiency, the maximum total utilization ratio, and the maximum time to maintain the HTF temperature at the outlet no lower than the desired value. It is shown that the preferred shape of TES depends on the choice of the efficiency criterion and specific process conditions such as boundary conditions, the phase transition temperature, etc. Narrowing and expanding TES shapes have an advantage in rare cases, while TES shapes with straight walls are often the most preferable.